Skip to content

Commit 98c22a2

Browse files
Merge pull request #21 from snyk/feat/passthrough-params
chore: Add flags we want to pass through to legacy CLI.
2 parents 02dee34 + 3f2cff7 commit 98c22a2

File tree

1 file changed

+95
-21
lines changed

1 file changed

+95
-21
lines changed

internal/flags/flags.go

Lines changed: 95 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,69 @@ package flags
22

33
import "github.com/spf13/pflag"
44

5-
// FlagFile is the filename of a single manifest file to test.
6-
const FlagFile = "file"
5+
// Defines the command-line flags used in the OS-Flows CLI extension.
6+
const (
7+
// Open Source.
8+
FlagFile = "file"
9+
FlagProjectName = "project-name"
10+
FlagRiskScoreThreshold = "risk-score-threshold"
11+
FlagSeverityThreshold = "severity-threshold"
12+
FlagUnifiedTestAPI = "unified-test"
713

8-
// FlagProjectName is the name of the project to test.
9-
const FlagProjectName = "project-name"
14+
// SBOM reachability.
15+
FlagReachability = "reachability"
16+
FlagSBOM = "sbom"
17+
FlagSourceDir = "source-dir"
1018

11-
// FlagRiskScoreThreshold is the flag for the minimum risk score for which findings are included.
12-
const FlagRiskScoreThreshold = "risk-score-threshold"
19+
// Passed through to legacy CLI.
20+
FlagAllProjects = "all-projects"
21+
FlagExperimental = "experimental"
22+
FlagUnmanaged = "unmanaged"
23+
FlagDetectionDepth = "detection-depth"
24+
FlagExclude = "exclude"
25+
FlagPruneRepeatedSubDependencies = "prune-repeated-subdependencies"
26+
FlagTargetReference = "target-reference"
27+
FlagPolicyPath = "policy-path"
28+
FlagMavenAggregateProject = "maven-aggregate-project"
29+
FlagScanUnmanaged = "scan-unmanaged"
30+
FlagScanAllUnmanaged = "scan-all-unmanaged"
31+
FlagSubProject = "sub-project"
32+
FlagAllSubProjects = "all-sub-projects"
33+
FlagGradleSubProject = "gradle-sub-project"
34+
FlagConfigurationMatching = "configuration-matching"
35+
FlagConfigurationAttributes = "configuration-attributes"
36+
FlagInitScript = "init-script"
37+
FlagNugetAssetsProjectName = "assets-project-name"
38+
FlagNugetPkgsFolder = "packages-folder"
39+
FlagDev = "dev"
40+
FlagNPMStrictOutOfSync = "strict-out-of-sync"
41+
FlagYarnWorkspaces = "yarn-workspaces"
42+
FlagPythonCommand = "command"
43+
FlagPythonSkipUnresolved = "skip-unresolved"
44+
FlagPythonPackageManager = "package-manager"
45+
FlagRemoteRepoURL = "remote-repo-url"
46+
FlagUnmanagedMaxDepth = "max-depth"
47+
FlagVersion = "version"
1348

14-
// FlagSeverityThreshold reports only vulnerabilities at the specified level or higher.
15-
const FlagSeverityThreshold = "severity-threshold"
16-
17-
// FlagUnifiedTestAPI forces use of the modern (non-legacy) workflow even without risk score threshold.
18-
const FlagUnifiedTestAPI = "unified-test"
19-
20-
// FlagReachability is used to request the reachability analysis of the source code.
21-
const FlagReachability = "reachability"
22-
23-
// FlagSBOM is used to specify the SBOM file to be tested. TODO: Revisit this after talking with design and product.
24-
const FlagSBOM = "sbom"
25-
26-
// FlagSourceDir is used to specify the source code directory to be tested.
27-
const FlagSourceDir = "source-dir"
49+
FlagFailFast = "fail-fast"
50+
FlagPrintDeps = "print-deps"
51+
FlagPrintDepPaths = "print-dep-paths"
52+
FlagOrg = "org"
53+
FlagIgnorePolicy = "ignore-policy"
54+
FlagTrustPolicies = "trust-policies"
55+
FlagShowVulnerablePaths = "show-vulnerable-paths"
56+
FlagFailOn = "fail-on"
57+
FlagProjectNamePrefix = "project-name-prefix"
58+
FlagDotnetRuntimeResolution = "dotnet-runtime-resolution"
59+
FlagDotnetTargetFramework = "dotnet-target-framework"
60+
)
2861

2962
// OSTestFlagSet returns a flag set for the Open Source Test workflow.
3063
func OSTestFlagSet() *pflag.FlagSet {
3164
flagSet := pflag.NewFlagSet("snyk-cli-extension-os-flows", pflag.ExitOnError)
3265

3366
// Open Source
34-
flagSet.String(FlagFile, "", "Specify a test subject file.")
67+
flagSet.String(FlagFile, "", "Specify a package file.")
3568
flagSet.String(FlagProjectName, "", "Specify a name for the project.")
3669

3770
flagSet.Bool(FlagUnifiedTestAPI, false, "Use the unified test API workflow.")
@@ -44,5 +77,46 @@ func OSTestFlagSet() *pflag.FlagSet {
4477
flagSet.String(FlagSBOM, "", "Specify an SBOM file to be tested.")
4578
flagSet.String(FlagSourceDir, "", "Path of the directory containing the source code.")
4679

80+
// Unused flags for passing to legacy CLI
81+
flagSet.Bool(FlagAllProjects, false, "Auto-detect all projects in the working directory (including Yarn workspaces).")
82+
flagSet.String(FlagExclude, "", "Can be used with --all-projects to indicate directory names and file names to exclude. Must be comma separated.")
83+
flagSet.String(FlagDetectionDepth, "", "Use with --all-projects to indicate how many subdirectories to search. "+
84+
"DEPTH must be a number, 1 or greater; zero (0) is the current directory.")
85+
flagSet.Bool(FlagExperimental, false, "Deprecated. Will be ignored.")
86+
flagSet.Bool(FlagUnmanaged, false, "For C/C++ only, scan all files for known open source dependencies and build an SBOM.")
87+
flagSet.Bool(FlagYarnWorkspaces, false, "Detect and scan Yarn Workspaces only when a lockfile is in the root.")
88+
flagSet.BoolP(FlagPruneRepeatedSubDependencies, "p", false, "Prune dependency trees, removing duplicate sub-dependencies.")
89+
flagSet.String(FlagVersion, "", "Specify a version for the collection of all projects in the working directory.")
90+
flagSet.Bool(FlagDev, false, "Include development-only dependencies. Applicable only for some package managers.")
91+
flagSet.Bool(FlagMavenAggregateProject, false, "Ensure all modules are resolvable by the Maven reactor.")
92+
flagSet.Bool(FlagScanUnmanaged, false, "Specify an individual JAR, WAR, or AAR file.")
93+
flagSet.Bool(FlagScanAllUnmanaged, false, "Auto-detect Maven, JAR, WAR, and AAR files recursively from the current folder.")
94+
flagSet.String(FlagSubProject, "", "Name of Gradle sub-project to test.")
95+
flagSet.String(FlagGradleSubProject, "", "Name of Gradle sub-project to test.")
96+
flagSet.Bool(FlagAllSubProjects, false, "Test all sub-projects in a multi-project build.")
97+
flagSet.String(FlagNPMStrictOutOfSync, "true", "Prevent testing out-of-sync lockfiles.")
98+
flagSet.Bool(FlagNugetAssetsProjectName, false,
99+
"When you are monitoring a .NET project using NuGet PackageReference uses the project name in project.assets.json if found.")
100+
flagSet.String(FlagNugetPkgsFolder, "", "Specify a custom path to the packages folder when using NuGet.")
101+
flagSet.String(FlagConfigurationMatching, "", "Resolve dependencies using only configuration(s) that match the specified Java regular expression.")
102+
flagSet.String(FlagConfigurationAttributes, "", "Select certain values of configuration attributes to install and resolve dependencies.")
103+
flagSet.String(FlagInitScript, "", "Use for projects that contain a Gradle initialization script.")
104+
flagSet.String(FlagPythonCommand, "", "Indicate which specific Python commands to use based on the Python version.")
105+
flagSet.String(FlagPythonSkipUnresolved, "", "Skip Python packages that cannot be found in the environment.")
106+
flagSet.String(FlagPythonPackageManager, "", `Add --package-manager=pip to your command if the file name is not "requirements.txt".`)
107+
flagSet.Int(FlagUnmanagedMaxDepth, 0, "Specify the maximum level of archive extraction for unmanaged scanning.")
108+
flagSet.Bool(FlagFailFast, false, "Stop scanning after the first vulnerability is found when used with --all-projects.")
109+
flagSet.Bool(FlagPrintDeps, false, "Print the dependency tree before sending it for analysis.")
110+
flagSet.Bool(FlagPrintDepPaths, false, "Display dependencies. Shows what files contributed to each dependency.")
111+
flagSet.String(FlagOrg, "", "Specify the <ORG_ID> to run Snyk commands tied to a specific organization.")
112+
flagSet.Bool(FlagIgnorePolicy, false, "Ignore all set policies, the current policy in the .snyk file, Org level ignores, and the project policy on snyk.io.")
113+
flagSet.Bool(FlagTrustPolicies, false, "Apply and use ignore rules from the Snyk policies in your dependencies.")
114+
flagSet.String(FlagShowVulnerablePaths, "", "Display the dependency paths from the top level dependencies down to the vulnerable packages.")
115+
flagSet.String(FlagFailOn, "", "Fail only when there are vulnerabilities that can be fixed.")
116+
flagSet.String(FlagProjectNamePrefix, "", "When monitoring a .NET project, use this option to add a custom prefix "+
117+
"to the name of files inside a project along with any desired separators.")
118+
flagSet.Bool(FlagDotnetRuntimeResolution, false, "You must use this option when you test .NET projects using Runtime Resolution Scanning.")
119+
flagSet.String(FlagDotnetTargetFramework, "", "Specify the target framework for .NET projects.")
120+
47121
return flagSet
48122
}

0 commit comments

Comments
 (0)