rename --scan-vulns to --vulns, add subcommand aliases, make check updates-only by default
This commit is contained in:
parent
d9445e06b5
commit
58d63b63ca
|
|
@ -92,7 +92,7 @@ dev-scan:
|
||||||
|
|
||||||
[group('dev')]
|
[group('dev')]
|
||||||
dev-full:
|
dev-full:
|
||||||
go run ./cmd/angela update --scan-vulns --file testdata/pyproject.toml
|
go run ./cmd/angela update --vulns --file testdata/pyproject.toml
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Build (Production)
|
# Build (Production)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
type updateFlags struct {
|
type updateFlags struct {
|
||||||
file string
|
file string
|
||||||
safe bool
|
safe bool
|
||||||
scanVulns bool
|
vulns bool
|
||||||
includePrerelease bool
|
includePrerelease bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,8 +61,9 @@ func newUpdateCmd() *cobra.Command {
|
||||||
f := &updateFlags{}
|
f := &updateFlags{}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "update",
|
Use: "update",
|
||||||
Short: "Update dependencies to latest stable versions",
|
Aliases: []string{"u"},
|
||||||
|
Short: "Update dependencies to latest stable versions",
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return runUpdate(cmd.Context(), f, false)
|
return runUpdate(cmd.Context(), f, false)
|
||||||
},
|
},
|
||||||
|
|
@ -77,7 +78,7 @@ func newUpdateCmd() *cobra.Command {
|
||||||
"skip major version bumps",
|
"skip major version bumps",
|
||||||
)
|
)
|
||||||
cmd.Flags().BoolVar(
|
cmd.Flags().BoolVar(
|
||||||
&f.scanVulns, "scan-vulns", false,
|
&f.vulns, "vulns", false,
|
||||||
"also scan for vulnerabilities",
|
"also scan for vulnerabilities",
|
||||||
)
|
)
|
||||||
cmd.Flags().BoolVar(
|
cmd.Flags().BoolVar(
|
||||||
|
|
@ -91,10 +92,10 @@ func newCheckCmd() *cobra.Command {
|
||||||
f := &updateFlags{}
|
f := &updateFlags{}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "check",
|
Use: "check",
|
||||||
Short: "Show available updates without modifying files",
|
Aliases: []string{"c"},
|
||||||
|
Short: "Show available updates without modifying files",
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
f.scanVulns = true
|
|
||||||
return runUpdate(cmd.Context(), f, true)
|
return runUpdate(cmd.Context(), f, true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +108,10 @@ func newCheckCmd() *cobra.Command {
|
||||||
&f.safe, "safe", false,
|
&f.safe, "safe", false,
|
||||||
"skip major version bumps",
|
"skip major version bumps",
|
||||||
)
|
)
|
||||||
|
cmd.Flags().BoolVar(
|
||||||
|
&f.vulns, "vulns", false,
|
||||||
|
"also scan for vulnerabilities",
|
||||||
|
)
|
||||||
cmd.Flags().BoolVar(
|
cmd.Flags().BoolVar(
|
||||||
&f.includePrerelease, "include-prerelease", false,
|
&f.includePrerelease, "include-prerelease", false,
|
||||||
"include pre-release versions",
|
"include pre-release versions",
|
||||||
|
|
@ -118,8 +123,9 @@ func newScanCmd() *cobra.Command {
|
||||||
var file string
|
var file string
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "scan",
|
Use: "scan",
|
||||||
Short: "Scan dependencies for known vulnerabilities",
|
Aliases: []string{"s"},
|
||||||
|
Short: "Scan dependencies for known vulnerabilities",
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return runScan(cmd.Context(), file)
|
return runScan(cmd.Context(), file)
|
||||||
},
|
},
|
||||||
|
|
@ -196,7 +202,7 @@ func runUpdate(
|
||||||
sortUpdates(updates)
|
sortUpdates(updates)
|
||||||
|
|
||||||
var vulns map[string][]types.Vulnerability
|
var vulns map[string][]types.Vulnerability
|
||||||
if f.scanVulns {
|
if f.vulns {
|
||||||
vulns = scanForVulns(ctx, deps)
|
vulns = scanForVulns(ctx, deps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,7 +230,7 @@ func runUpdate(
|
||||||
TotalPackages: len(deps),
|
TotalPackages: len(deps),
|
||||||
TotalUpdated: len(updateSpecs),
|
TotalUpdated: len(updateSpecs),
|
||||||
TotalVulns: totalVulns,
|
TotalVulns: totalVulns,
|
||||||
VulnsScanned: f.scanVulns,
|
VulnsScanned: f.vulns,
|
||||||
Duration: time.Since(start),
|
Duration: time.Since(start),
|
||||||
}, !dryRun && len(updateSpecs) > 0)
|
}, !dryRun && len(updateSpecs) > 0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue