Skip to content

Add Semgrep SAST gate; fix crypto RNG + hygiene - #37

Merged
stremovsky merged 1 commit into
masterfrom
add-semgrep-sast
Jul 26, 2026
Merged

Add Semgrep SAST gate; fix crypto RNG + hygiene#37
stremovsky merged 1 commit into
masterfrom
add-semgrep-sast

Conversation

@stremovsky

Copy link
Copy Markdown
Contributor

Security fix: RandSeq/RandNum — which generate 6-digit verification & captcha codes — used time-seeded math/rand (predictable). Switched to crypto/rand via a secureIntn helper.

Hygiene:

  • Pin actions/checkout + actions/setup-go to commit SHAs in cy.yml.
  • Enable RDS CloudWatch log exports (terraform/aws/rds.tf).

Suppressed verified false positives (with justification):

  • Non-crypto MD5 (data-sanity checksums / indexing) ×7
  • json.Unmarshal into interface{} — safe in Go ×5
  • DDL fmt.Sprintf queries (identifiers can’t be parameterized) ×4
  • Replaced the README example RSA private key with a placeholder.

Gate: self-contained semgrep.yml (public repo → inline; master branch), blocking, p/golang + common packs. Scans to 0 findings; go build clean.

🤖 Generated with Claude Code

…ives

- Security fix: RandSeq/RandNum (verification/captcha codes) now use crypto/rand instead of time-seeded math/rand
- Pin actions/checkout + actions/setup-go to commit SHAs in cy.yml
- Enable RDS CloudWatch log exports
- Suppress verified false positives (non-crypto MD5, json.Unmarshal into interface{}, DDL string-format); replace README example RSA key with a placeholder
- Add self-contained semgrep.yml gate (public repo; master branch); 0 findings

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Comment thread src/service.go
os.Exit(0)
}
md5hash := md5.Sum(masterKey)
md5hash := md5.Sum(masterKey) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
Comment thread src/service.go
log.Printf("Master key: %x\n", masterKey)
}
md5hash := md5.Sum(masterKey)
md5hash := md5.Sum(masterKey) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
}
fmt.Printf("** recreate database: %s\n", testDBName)
_, err = db.Exec(fmt.Sprintf("drop database %s", testDBName))
_, err = db.Exec(fmt.Sprintf("drop database %s", testDBName)) // nosemgrep: go.lang.security.audit.database.string-formatted-query.string-formatted-query -- DDL with a controlled identifier; db/table names cannot be parameterized
fmt.Printf("error: %s\n", err)
}
_, err = db.Exec(fmt.Sprintf("create database %s", testDBName))
_, err = db.Exec(fmt.Sprintf("create database %s", testDBName)) // nosemgrep: go.lang.security.audit.database.string-formatted-query.string-formatted-query -- DDL with a controlled identifier; db/table names cannot be parameterized
}
fmt.Printf("** recreate database: %s\n", testDBName)
_, err = db.Exec(fmt.Sprintf("drop database %s", testDBName))
_, err = db.Exec(fmt.Sprintf("drop database %s", testDBName)) // nosemgrep: go.lang.security.audit.database.string-formatted-query.string-formatted-query -- DDL with a controlled identifier; db/table names cannot be parameterized
Comment thread src/userapps_db.go
bdoc["data"] = encodedStr
//it is ok to use md5 here, it is only for data sanity
md5Hash := md5.Sum([]byte(encodedStr))
md5Hash := md5.Sum([]byte(encodedStr)) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
Comment thread src/userapps_db.go
bdoc["data"] = encodedStr
//it is ok to use md5 here, it is only for data sanity
md5Hash := md5.Sum([]byte(encodedStr))
md5Hash := md5.Sum([]byte(encodedStr)) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
Comment thread src/users_db.go
bdoc["data"] = encodedStr
//it is ok to use md5 here, it is only for data sanity
md5Hash := md5.Sum([]byte(encodedStr))
md5Hash := md5.Sum([]byte(encodedStr)) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
Comment thread src/users_db.go
bdoc["data"] = encodedStr
//it is ok to use md5 here, it is only for data sanity
md5Hash := md5.Sum([]byte(encodedStr))
md5Hash := md5.Sum([]byte(encodedStr)) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
Comment thread src/users_db.go
bdoc["key"] = userKey
bdoc["data"] = encodedStr
md5Hash := md5.Sum([]byte(encodedStr))
md5Hash := md5.Sum([]byte(encodedStr)) // nosemgrep: go.lang.security.audit.crypto.use_of_weak_crypto.use-of-md5 -- non-cryptographic checksum (data sanity / indexing), not a security hash
@stremovsky
stremovsky merged commit 42a219e into master Jul 26, 2026
8 checks passed
@stremovsky
stremovsky deleted the add-semgrep-sast branch July 26, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants