Review dependency integrity and vulnerabilities
Review dependency integrity and vulnerabilities
Go modules pin dependency versions through go.mod; go.sum records cryptographic hashes used to verify downloaded module content. This helps detect unexpected content changes but does not establish that a module is safe. Review module additions and replacements, maintain supported toolchains and check official advisories. This example reads metadata embedded in its own executable, with no network calls.
package main
import ( "fmt" "runtime/debug")
func main() { b, ok := debug.ReadBuildInfo() fmt.Println(ok, ok && b.GoVersion != "")}ReadBuildInfo reports available build metadata. Module dependencies in a binary are useful inventory evidence, not a full inventory of source, build tools or runtime components. Inspect go.mod, go.sum, go list -m all, and go version -m for approved artifacts. Review replace directives and private module checksum policy. Never publish internal dependency paths or credentials in logs.
Expected output:
true truePrioritize a synthetic advisory
package main
import ( "fmt")
type Finding struct{ Affected, Reachable, FixedAvailable bool }
func needsReview(f Finding) bool { return f.Affected }func priority(f Finding) string { if !f.Affected { return "not-affected" } if f.Reachable { return "urgent-review" } return "review"}func main() { fmt.Println(priority(Finding{true, true, true}), priority(Finding{true, false, true}), priority(Finding{false, false, false}))}This toy classification is not a scanner or risk score. Use go mod verify to check cached module content against recorded hashes, and an approved version of govulncheck to assess known vulnerabilities in code and dependencies. A finding requires version, reachability, exposure and business-context review; lack of findings is not a guarantee of security. Plan updates, run regression tests and recheck findings. No vulnerability database was queried in this exercise.
Expected output:
urgent-review review not-affectedTry it locally
Print whether the executable reports a Go version and whether build metadata is available.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Security engineering 10: Review dependency integrity and vulnerabilities
Check the lesson objective before moving on.
What does a verified module checksum prove?
What is a sensible response to an affected but currently unreachable dependency?