Skip to content

Commit 938fcd6

Browse files
Merge pull request #4 from isaquepinheiro/fix/gosec-nosec
fix(security): use #nosec so the standalone gosec scan sees the suppressions
2 parents 87327f4 + c9ce3ef commit 938fcd6

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

internal/adapters/primary/cli/contribute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func submitPullRequest(
271271

272272
// Helper to run git commands.
273273
func runGitCmd(ctx context.Context, dir string, args ...string) (string, error) {
274-
//nolint:gosec // G204: fixed git binary; arguments are built by this CLI
274+
// #nosec G204 -- fixed git binary; arguments are built by this CLI
275275
cmd := exec.CommandContext(ctx, "git", args...)
276276
cmd.Dir = dir
277277
var stdout, stderr bytes.Buffer

internal/adapters/primary/cli/pubpascal.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func LoadPubPascalConfig() (*PubPascalConfig, error) {
141141
return config, nil
142142
}
143143

144-
//nolint:gosec // G304: the path is this CLI's own config in the user's home
144+
// #nosec G304 -- the path is this CLI's own config in the user's home
145145
data, err := os.ReadFile(configPath)
146146
if err != nil {
147147
return config, err
@@ -167,7 +167,7 @@ func SavePubPascalConfig(config *PubPascalConfig) error {
167167

168168
// Persisting the token is the whole purpose of this file: it is written
169169
// with mode 0600 into the user's home and never sent anywhere else.
170-
//nolint:gosec // G117: the portal token is stored locally on purpose
170+
// #nosec G117 -- the portal token is stored locally on purpose
171171
data, err := json.MarshalIndent(config, "", " ")
172172
if err != nil {
173173
return err
@@ -494,7 +494,7 @@ func cloneWorkspaceRepo(
494494
return cloneFailed
495495
}
496496

497-
//nolint:gosec // G204: fixed git binary; URL and path come from the portal manifest
497+
// #nosec G204 -- fixed git binary; URL and path come from the portal manifest
498498
cloneCmd := exec.CommandContext(ctx, "git", "clone", repo.CloneURL, repoPath)
499499
cloneCmd.Stdout = os.Stdout
500500
cloneCmd.Stderr = os.Stderr
@@ -505,7 +505,7 @@ func cloneWorkspaceRepo(
505505

506506
// Checkout ref if specified
507507
if repo.Ref.HasRef && repo.Ref.Value != "" {
508-
//nolint:gosec // G204: fixed git binary; ref comes from the portal manifest
508+
// #nosec G204 -- fixed git binary; ref comes from the portal manifest
509509
checkoutCmd := exec.CommandContext(ctx, "git", "-C", repoPath, "checkout", repo.Ref.Value)
510510
checkoutCmd.Stdout = os.Stdout
511511
checkoutCmd.Stderr = os.Stderr
@@ -544,7 +544,7 @@ func createCodenameBranch(ctx context.Context, repoPath string, codename string)
544544
}
545545

546546
newBranch := baseBranch + "-" + codename
547-
//nolint:gosec // G204: fixed git binary; branch name derives from the repo HEAD
547+
// #nosec G204 -- fixed git binary; branch name derives from the repo HEAD
548548
createBranchCmd := exec.CommandContext(ctx, "git", "-C", repoPath, "checkout", "-b", newBranch)
549549
if err := createBranchCmd.Run(); err != nil {
550550
msg.Warn(" Warning: could not create branch %s (continuing)", newBranch)
@@ -575,7 +575,7 @@ func runBossInstall(ctx context.Context, repoPath string, repoSubdir string) {
575575
// reports whether git exited successfully; callers that only need the output
576576
// treat a failure as "no information available".
577577
func gitCapture(ctx context.Context, path string, args ...string) (string, bool) {
578-
//nolint:gosec // G204: fixed git binary; the arguments are built by this CLI
578+
// #nosec G204 -- fixed git binary; the arguments are built by this CLI
579579
cmd := exec.CommandContext(ctx, "git", append([]string{"-C", path}, args...)...)
580580
var out bytes.Buffer
581581
cmd.Stdout = &out
@@ -592,7 +592,7 @@ func isGitRepo(path string) bool {
592592
}
593593

594594
func isDirPopulated(path string) bool {
595-
//nolint:gosec // G304: path is built from the workspace manifest, not user input
595+
// #nosec G304 -- path is built from the workspace manifest, not user input
596596
f, err := os.Open(path)
597597
if err != nil {
598598
return false
@@ -625,7 +625,7 @@ func injectDprojPaths(cwd string, repos []ManifestRepo, rootRepoName string) {
625625
return
626626
}
627627

628-
//nolint:gosec // G304: the path is a .dproj discovered inside the cloned workspace
628+
// #nosec G304 -- the path is a .dproj discovered inside the cloned workspace
629629
content, err := os.ReadFile(dprojPath)
630630
if err != nil {
631631
return
@@ -638,7 +638,7 @@ func injectDprojPaths(cwd string, repos []ManifestRepo, rootRepoName string) {
638638

639639
// os.WriteFile keeps the mode of an already existing file, so the value
640640
// below only applies if the .dproj disappeared between read and write.
641-
//nolint:gosec // G703: dprojPath comes from a Glob inside the cloned workspace
641+
// #nosec G703 -- dprojPath comes from a Glob inside the cloned workspace
642642
if err := os.WriteFile(dprojPath, []byte(updatedXML), 0600); err != nil {
643643
msg.Err("❌ Failed to save updated .dproj file: %s", err)
644644
} else {
@@ -859,7 +859,7 @@ func runWorkspaceUpdate(ctx context.Context) {
859859

860860
for _, repoPath := range discoverWorkspaceRepos(cwd) {
861861
msg.Info("Updating %s...", filepath.Base(repoPath))
862-
//nolint:gosec // G204: fixed git binary; repoPath is a directory found on disk
862+
// #nosec G204 -- fixed git binary; repoPath is a directory found on disk
863863
pullCmd := exec.CommandContext(ctx, "git", "-C", repoPath, "pull", "--ff-only")
864864
pullCmd.Stdout = os.Stdout
865865
pullCmd.Stderr = os.Stderr
@@ -890,7 +890,7 @@ func runWorkspacePush(ctx context.Context) {
890890
}
891891

892892
msg.Info("Pushing changes in %s...", filepath.Base(repoPath))
893-
//nolint:gosec // G204: fixed git binary; repoPath is a directory found on disk
893+
// #nosec G204 -- fixed git binary; repoPath is a directory found on disk
894894
pushCmd := exec.CommandContext(ctx, "git", "-C", repoPath, "push")
895895
pushCmd.Stdout = os.Stdout
896896
pushCmd.Stderr = os.Stderr
@@ -1210,7 +1210,7 @@ func runPkgPublishSbom(ctx context.Context, slug string, version string, sbomFil
12101210
}
12111211

12121212
msg.Info("Publishing SBOM for %s@%s to the portal...", slug, version)
1213-
//nolint:gosec // G304: the path is the SBOM file the user asked to upload
1213+
// #nosec G304 -- the path is the SBOM file the user asked to upload
12141214
data, err := os.ReadFile(sbomFile)
12151215
if err != nil {
12161216
msg.Die("❌ Failed to read SBOM file: %s", err)
@@ -1277,7 +1277,7 @@ func runPkgSpec(id string, version string) {
12771277
func runPkgPack(specFile string, outputDir string) {
12781278
msg.Info("Packaging Delphi library based on manifest: %s", specFile)
12791279
// Read manifest
1280-
//nolint:gosec // G304: the path is the manifest the user pointed --spec at
1280+
// #nosec G304 -- the path is the manifest the user pointed --spec at
12811281
data, err := os.ReadFile(specFile)
12821282
if err != nil {
12831283
msg.Die("❌ Failed to read manifest file: %s", err)

0 commit comments

Comments
 (0)