Skip to content

[K9VULN-11116] Fix panic when unable to open file during lockfile scanning#100

Merged
piloulacdog merged 1 commit intomainfrom
dastrong/K9VULN-11116
Jan 23, 2026
Merged

[K9VULN-11116] Fix panic when unable to open file during lockfile scanning#100
piloulacdog merged 1 commit intomainfrom
dastrong/K9VULN-11116

Conversation

@dastrong
Copy link
Copy Markdown
Collaborator

🚀 Motivation

The scanner would panicking with a nil pointer dereference when attempting to close a file that failed to open. This panic was swallowing the actual scan failure reason, making it difficult to diagnose why certain repository scan failures occur.

📝 Summary

Changed the control flow in scanLockfile function to handle file opening errors properly. Instead of attempting to close a nil file pointer when OpenLocalDepFile fails, the function now returns early with the error. The deferred file.Close() call is now only executed when the file was successfully opened, preventing the nil pointer dereference panic.

@dastrong dastrong requested a review from a team as a code owner January 22, 2026 21:59
@github-actions
Copy link
Copy Markdown

Go test coverage report

Total test coverage: 90.5% (4336/4792)

Test coverage has changed in the current files, with 21 lines missing coverage.
file: uncovered: current coverage: base coverage:
pkg/scanner/datadog_sbom_generator.go 21 85.8% (127/148) 86.4% (127/147)

Copy link
Copy Markdown
Contributor

@piloulacdog piloulacdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test... but let's get it out

@piloulacdog piloulacdog merged commit c498c7c into main Jan 23, 2026
10 checks passed
@piloulacdog piloulacdog deleted the dastrong/K9VULN-11116 branch January 23, 2026 07:44
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