From 94a33844a09f6e5c92735d301e351daa1c193db5 Mon Sep 17 00:00:00 2001 From: Dmitrii Pavlukhin Date: Mon, 15 Apr 2024 16:12:13 +0300 Subject: [PATCH] detectExecuteScan - Removed option to change min-scan-interval for Signature Scan to enforce global interval value (#4875) * removed option to change min-scan-interval to enforce global interval value * returned-param-to-avoid-pipeline-breaks * fix-for-tests --- cmd/detectExecuteScan.go | 6 ------ cmd/detectExecuteScan_generated.go | 2 +- cmd/detectExecuteScan_test.go | 8 -------- resources/metadata/detectExecuteScan.yaml | 4 +++- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/cmd/detectExecuteScan.go b/cmd/detectExecuteScan.go index 106708ded1..bc5b5b316c 100644 --- a/cmd/detectExecuteScan.go +++ b/cmd/detectExecuteScan.go @@ -426,12 +426,6 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU args = append(args, fmt.Sprintf("--detect.excluded.directories=%s", strings.Join(config.ExcludedDirectories, ","))) } - if config.MinScanInterval > 0 { - //Unmap doesnt work well with min-scan-interval and should be removed - config.Unmap = false - args = append(args, fmt.Sprintf("--detect.blackduck.signature.scanner.arguments='--min-scan-interval=%d'", config.MinScanInterval)) - } - if config.Unmap { if !piperutils.ContainsString(config.ScanProperties, "--detect.project.codelocation.unmap=true") { args = append(args, "--detect.project.codelocation.unmap=true") diff --git a/cmd/detectExecuteScan_generated.go b/cmd/detectExecuteScan_generated.go index 0250f6ce38..9d72b8991e 100644 --- a/cmd/detectExecuteScan_generated.go +++ b/cmd/detectExecuteScan_generated.go @@ -300,7 +300,7 @@ func addDetectExecuteScanFlags(cmd *cobra.Command, stepConfig *detectExecuteScan cmd.Flags().BoolVar(&stepConfig.ScanOnChanges, "scanOnChanges", false, "This flag determines if the scan is submitted to the server. If set to true, then the scan request is submitted to the server only when changes are detected in the Open Source Bill of Materials If the flag is set to false, then the scan request is submitted to server regardless of any changes. For more details please refer to the [documentation](https://github.com/blackducksoftware/detect_rescan/blob/master/README.md)") cmd.Flags().BoolVar(&stepConfig.SuccessOnSkip, "successOnSkip", true, "This flag allows forces Black Duck to exit with 0 error code if any step is skipped") cmd.Flags().StringSliceVar(&stepConfig.CustomEnvironmentVariables, "customEnvironmentVariables", []string{}, "A list of environment variables which can be set to prepare the environment to run a BlackDuck scan. This includes a list of environment variables defined by Synopsys. The full list can be found [here](https://community.synopsys.com/s/document-item?bundleId=integrations-detect&topicId=configuring%2Fenvvars.html&_LANG=enus) This list affects the detect script downloaded while running the scan. Right now only detect7.sh is available for downloading") - cmd.Flags().IntVar(&stepConfig.MinScanInterval, "minScanInterval", 0, "This parameter controls the frequency (in number of hours) at which the signature scan is re-submitted for scan. When set to a value greater than 0, the signature scans are skipped until the specified number of hours has elapsed since the last signature scan.") + cmd.Flags().IntVar(&stepConfig.MinScanInterval, "minScanInterval", 0, "[DEPRECATED] This parameter controls the frequency (in number of hours) at which the signature scan is re-submitted for scan. When set to a value greater than 0, the signature scans are skipped until the specified number of hours has elapsed since the last signature scan.") cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line") cmd.Flags().BoolVar(&stepConfig.CreateResultIssue, "createResultIssue", false, "Activate creation of a result issue in GitHub.") cmd.Flags().StringVar(&stepConfig.GithubAPIURL, "githubApiUrl", `https://api.github.com`, "Set the GitHub API URL.") diff --git a/cmd/detectExecuteScan_test.go b/cmd/detectExecuteScan_test.go index 2787908ce3..d6288fd53d 100644 --- a/cmd/detectExecuteScan_test.go +++ b/cmd/detectExecuteScan_test.go @@ -700,11 +700,9 @@ func TestAddDetectArgs(t *testing.T) { VersioningModel: "major-minor", CodeLocation: "", ScanPaths: []string{"path1", "path2"}, - MinScanInterval: 4, }, expected: []string{ "--testProp1=1", - "--detect.blackduck.signature.scanner.arguments='--min-scan-interval=4'", "--blackduck.url=https://server.url", "--blackduck.api.token=apiToken", "\"--detect.project.name=testName\"", @@ -725,13 +723,11 @@ func TestAddDetectArgs(t *testing.T) { VersioningModel: "major-minor", CodeLocation: "", ScanPaths: []string{"path1", "path2"}, - MinScanInterval: 4, CustomScanVersion: "1.0", }, isPullRequest: true, expected: []string{ "--testProp1=1", - "--detect.blackduck.signature.scanner.arguments='--min-scan-interval=4'", "--blackduck.url=https://server.url", "--blackduck.api.token=apiToken", "\"--detect.project.name=Rapid_scan_on_PRs\"", @@ -763,13 +759,11 @@ func TestAddDetectArgs(t *testing.T) { "--detect.excluded.directories=dir1,dir2", }, ExcludedDirectories: []string{"dir3,dir4"}, - MinScanInterval: 4, CustomScanVersion: "2.0", }, isPullRequest: true, expected: []string{ "--testProp1=1", - "--detect.blackduck.signature.scanner.arguments='--min-scan-interval=4'", "--detect.detector.search.depth=5", "--detect.detector.search.continue=false", "--detect.excluded.directories=dir1,dir2", @@ -802,13 +796,11 @@ func TestAddDetectArgs(t *testing.T) { ScanProperties: []string{ "--detect.maven.build.command= --settings .pipeline/settings.xml -DskipTests install", }, - MinScanInterval: 4, CustomScanVersion: "2.0", }, isPullRequest: true, expected: []string{ "--testProp1=1", - "--detect.blackduck.signature.scanner.arguments='--min-scan-interval=4'", "--detect.maven.build.command=", "--settings", ".pipeline/settings.xml", diff --git a/resources/metadata/detectExecuteScan.yaml b/resources/metadata/detectExecuteScan.yaml index 2110312a2e..747559bc36 100644 --- a/resources/metadata/detectExecuteScan.yaml +++ b/resources/metadata/detectExecuteScan.yaml @@ -340,15 +340,17 @@ spec: - PARAMETERS - STAGES - STEPS + ## --- to remove minScanInterval from parameters list --- - name: minScanInterval description: - "This parameter controls the frequency (in number of hours) at which the signature scan is re-submitted for scan. When set to a + "[DEPRECATED] This parameter controls the frequency (in number of hours) at which the signature scan is re-submitted for scan. When set to a value greater than 0, the signature scans are skipped until the specified number of hours has elapsed since the last signature scan." type: int scope: - PARAMETERS - STAGES - STEPS + ## ----------- - name: githubToken description: "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line"