Building 70 Projects ranging from beginner to advanced so anyone can β learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company π
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
add angela init command to scaffold pyproject.toml with config
CarterPerez-devb0c58a529d72
diff --git a/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go b/PROJECTS/simple-vulnerability-scanner/internal/cli/update.goindex 9c9e9044..bb6f887f 100644--- a/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go+++ b/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go@@ -60,6 +60,7 @@ latest stable versions, and checks for known CVEs using OSV.dev.`,)root.AddCommand(+ newInitCmd(),newUpdateCmd(),newCheckCmd(),newScanCmd(),@@ -72,6 +73,55 @@ latest stable versions, and checks for known CVEs using OSV.dev.`,}}+const pyprojectTemplate = `[project]+name = "%s"+version = "0.1.0"+description = ""+requires-python = ">=3.13"+dependencies = []++[tool.angela]+# Minimum severity to report (critical, high, moderate, low)+# min-severity = "moderate"++# Dependencies to skip during updates+# ignore = []++# Vulnerability IDs to suppress (accepted risk)+# ignore-vulns = []+`++func newInitCmd() *cobra.Command {+ return &cobra.Command{+ Use: "init",+ Short: "Create a new pyproject.toml with angela configuration",+ RunE: func(_ *cobra.Command, _ []string) error {+ return runInit()+ },+ }+}++func runInit() error {+ if _, err := os.Stat("pyproject.toml"); err == nil {+ return fmt.Errorf("pyproject.toml already exists")+ }++ dir, err := os.Getwd()+ if err != nil {+ return fmt.Errorf("get working directory: %w", err)+ }++ name := filepath.Base(dir)+ content := fmt.Sprintf(pyprojectTemplate, name)++ if err := os.WriteFile("pyproject.toml", []byte(content), 0o644); err != nil { //nolint:gosec+ return fmt.Errorf("write pyproject.toml: %w", err)+ }++ fmt.Printf("\n %s pyproject.toml\n\n", greenBold("Created"))+ return nil+}+func newUpdateCmd() *cobra.Command {f := &updateFlags{}