Package: ws-cleanup-tool-test
Mend Projects Cleanup CLI ToolThe self-hosted CLI tool features cleaning up projects and generating reports before deletion in 2 modes:By statingOperationMode=FilterProjectsByUpdateTimeand how many days to keep (-r/ DaysToKeep=)By statingOperationMode=FilterProjectsByLastCreatedCopiesand how many copies to keep (-r/ DaysToKeep=)The reports are saved in the designated location as follows:[Output_DIR]/[PRODUCT NAME]/[PROJECT NAME]/[REPORT NAME]The default location is the[WORKING DIRECTORY]/Mend/Reports/[PRODUCT NAME]/[PROJECT NAME]/[REPORT NAME]To review the outcome before actual deletion use-y true/DryRun=Trueflag. It willNOTdelete any project nor create reportsBy default, the tool generates all possible project-level reports. By specifying ((-t/Reports=/) it is possible to select specific reportsThe full list of available reports is belowThe full parameters list is available belowThere are two ways to configure the tool:By configuringparams.configon the executed dir or passing a path to the file in the same formatBy setting command line parameters as specified in the usage belowSupported Operating SystemsLinux (Bash):CentOS, Debian, Ubuntu, RedHatWindows (PowerShell):10, 2012, 2016Pre-requisitesPython 3.8+PermissionsThe user used to execute the tool has to have "Organization Administrator" or "Product Administrator" on all the maintained products and "Organization Auditor" permissions.It is recommended to use a service user.Installation and Execution from PyPi (recommended):Install by executing:pip install mend-sca-cleanup-toolConfigure the appropriate parameters either by using the command line or inparams.config.Execute the tool (mend_sca_cleanup_tool ...).Installation and Execution from GitHub:Download and unzipmend-sca-cleanup-tool.zipfrom the most recent tagged release.Install requirements:pip install -r requirements.txtConfigure the appropriate parameters either by using the command line orparams.config.Execute:python sca_cleanup_tool.py <CONFIG_FILE>Examples:Perform dry run check-in to get to know which projects would have been deleted:mend_sca_cleanup_tool -r 30 -m FilterProjectsByUpdateTime -u <USER_KEY> -k <ORG_TOKEN> -y trueKeep the last 60 days on each product, omitting a product token <PRODUCT_1> from analyzing:mend_sca_cleanup_tool -r 60 -m FilterProjectsByUpdateTime -u <USER_KEY> -k <ORG_TOKEN> -e <PRODUCT_TOKEN_1>Keep only two of the newest projects in each product token PRODUCT_1 and PRODUCT_2:mend_sca_cleanup_tool -r 2 -m FilterProjectsByLastCreatedCopies -u <USER_KEY> -k <ORG_TOKEN> -i <PRODUCT_TOKEN_1>,<PRODUCT_TOKEN_2>Analyze only the projects that have the specified Mend tag and keep the newest project in each product:mend_sca_cleanup_tool -r 1 -m FilterProjectsByLastCreatedCopies -u <USER_KEY> -k <ORG_TOKEN> -g <KEY>:<VALUE>Keep the last 2 weeks and analyze only the projects whose match their tag key and the tag value contains the specified value:mend_sca_cleanup_tool -r 14 -m FilterProjectsByUpdateTime -u <USER_KEY> -k <ORG_TOKEN> -v <KEY>:<VALUE>Keep the last 100 days for both PRODUCT_1 and PRODUCT_2, but do not delete the project PROJECT_1 (which is a project in one of the included products):mend_sca_cleanup_tool -r 100 -m FilterProjectsByUpdateTime -u <USER_KEY> -k <ORG_TOKEN> -i <PRODUCT_TOKEN_1>,<PRODUCT_TOKEN_2> -x <PROJECT_TOKEN_1>Keep the last month for both PRODUCT_1 and PRODUCT_2, but do not delete projects that contain provided strings in their names:mend_sca_cleanup_tool -r 31 -m FilterProjectsByUpdateTime -u <USER_KEY> -k <ORG_TOKEN> -i <PRODUCT_TOKEN_1>,<PRODUCT_TOKEN_2> -n CI_,-testFull Usage flags:usage:ws_cleanup_tool[-h]-uMEND_USER_KEY-kMEND_TOKEN[-aMEND_URL][-tREPORT_TYPES][-m{FilterProjectsByUpdateTime,FilterProjectsByLastCreatedCopies}][-oOUTPUT_DIR][-eEXCLUDED_PRODUCT_TOKENS][-iINCLUDED_PRODUCT_TOKENS][-gANALYZED_PROJECT_TAG][-rDAYS_TO_KEEP][-pPROJECT_PARALLELISM_LEVEL][-yDRY_RUN]MendCleanupTool

optionalarguments:-h,--helpshowthishelpmessageandexit-uMEND_USER_KEY,--userKeyMendUserKey-kMEND_API_TOKEN,--apiToken,--orgTokenMendOrganizationKey(APIKey)-aMEND_URL,--mendUrl,--wsURLMendURL.Thisvaluedefaultstosaas.whitesourcesoftware.com.-tREPORT_TYPES,--reportTypesReportTypestogenerate(commaseperatedlist)-mOPERATION_MODE,--operationMode{FilterProjectsByUpdateTime,FilterProjectsByLastCreatedCopies}Cleanupoperationmode-oOUTPUT_DIR,--outputDirOutputdirectory-eEXCLUDED_PRODUCT_TOKENS,--excludedProductTokensListofexcludedproducts-iINCLUDED_PRODUCT_TOKENS,--includedProductTokensListofincludedproducts-gANALYZED_PROJECT_TAG,--AnalyzedProjectTagAnalyzeonlytheprojectswhosecontainthespecificMendtag(key:value).Casesensitive.-vANALYZED_PROJECT_TAG_REGEX_IN_VALUE,--AnalyzedProjectTagRegexInValueAnalyzeonlytheprojectswhosematchtheirtagkeyandthetagvaluecontainsthespecifiedvalue(key:value).Casesensitive.Note:Thiswasoriginallybrokenintheoriginalws-cleanup-tool.Thefunctionalitywasadjustedtoworkasoriginallywritten.Thenamingconventionisamisnomerbutwaskepttoavoidbreakingexistingintegrations.-rDAYS_TO_KEEP,--DaysToKeepNumberofdaystokeepinFilterProjectsByUpdateTimeornumberofcopiesinFilterProjectsByLastCreatedCopies-pPROJECT_PARALLELISM_LEVEL,--ProjectParallelismLevelProjectparallelismlevelNote:Thisiscurrentlynotusedinthisversionofthemend-sca-cleanup-tool.Waskepttopreventbreakingexistingintegrations.-yDRY_RUN,--DryRunLoggingtheprojectsthataresupposedtobedeletedwithoutdeletingandcreatingreportsdefaultFalse-sSKIP_REPORT_GENERATION,--SkipReportGenerationSkipreportgenerationstepdefaultFalse-jSKIP_PROJECT_DELETION,--SkipProjectDeletionSkipprojectdeletionstepdefaultFalse-xEXCLUDED_PROJECT_TOKENS,--excludedProjectTokensListofexcludedprojects-nEXCLUDED_PROJECT_NAME_PATTERNS,--excludedProjectNamePatternsListofexcludedprojectnamepatterns(commaseperatedlist).Casesensitive.Available reportsThe following Mend project reports are available through the clean-up tool. These values can be specified with the -t flag to generate specific reports.alertsalerts_rejected_by_policyattributionbugsdue_diligenceignored_alertsin_house_librariesinventorylicense_compatibilityresolved_alertsrequest_historysource_filessource_file_inventoryvulnerabilitySAST Clean upIf you need to run a clean up script for your SAST environment, please refer to the Mend SAST clean up kit in theMend Toolkitnote:The optimal cleanup scope is derived from the size of the environment, Mend scope size (memory and CPU) allocated for the server, and runtime time constraints.