scan

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ScanCmd = &cobra.Command{
	Use:   "scan [flags]",
	Short: "Scan for CANARY tokens and generate reports",
	Long: `Scan source code for CANARY tokens and generate status reports.

This command scans your codebase for CANARY tokens and generates JSON/CSV reports.
Uses the built-in scanner; works from any directory when canary is installed via go install.

Flags:
  --root <dir>            Root directory to scan (default ".")
  --out <file>            Output status.json path (default "status.json")
  --csv <file>            Optional status.csv path
  --verify <file>         GAP_ANALYSIS file to verify claims
  --strict                Enforce staleness on TESTED/BENCHED tokens (default 30 days; see --stale-days)
  --update-stale          Rewrite UPDATED field for stale tokens
  --skip <regex>          Skip path regex (RE2)
  --project-only          Filter by project requirement ID pattern
  --stale-days <n>        Staleness window in days (0 = use .canary/project.yaml verification.staleness_days, else 30)

Examples:
  # Basic scan
  canary scan --root . --out status.json

  # Verify GAP_ANALYSIS.md claims
  canary scan --verify GAP_ANALYSIS.md

  # Update stale tokens
  canary scan --update-stale

  # Strict mode with staleness enforcement
  canary scan --strict`,
	RunE: func(cmd *cobra.Command, args []string) error {
		rootDir, _ := cmd.Flags().GetString("root")
		out, _ := cmd.Flags().GetString("out")
		csv, _ := cmd.Flags().GetString("csv")
		verify, _ := cmd.Flags().GetString("verify")
		strict, _ := cmd.Flags().GetBool("strict")
		updateStale, _ := cmd.Flags().GetBool("update-stale")
		skipStr, _ := cmd.Flags().GetString("skip")
		projectOnly, _ := cmd.Flags().GetBool("project-only")
		staleDays, _ := cmd.Flags().GetInt("stale-days")

		skip := canaryscan.DefaultSkipRegex()
		if skipStr != "" {
			var err error
			skip, err = regexp.Compile(skipStr)
			if err != nil {
				return err
			}
		}

		cfg := canaryscan.Config{
			Root:        rootDir,
			Out:         out,
			CSV:         csv,
			VerifyPath:  verify,
			Strict:      strict,
			SkipRegex:   skip,
			UpdateStale: updateStale,
			ProjectOnly: projectOnly,
			StaleDays:   staleDays,
		}
		code := canaryscan.Run(cfg, os.Stdout, os.Stderr)
		if code != 0 {
			os.Exit(code)
		}
		return nil
	},
}

CANARY: REQ=ENG-4302; FEATURE="ScanCmd"; ASPECT=CLI; STATUS=IMPL; OWNER=canary; UPDATED=2025-10-17 ScanCmd uses the built-in canaryscan package so scan works from any CWD (e.g. after go install).

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL