Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan specific file #2041

Closed
metametadata opened this issue Aug 7, 2024 · 2 comments · Fixed by #2120
Closed

Scan specific file #2041

metametadata opened this issue Aug 7, 2024 · 2 comments · Fixed by #2120
Labels
changelog-ignore Don't include this issue in the release changelog enhancement New feature or request

Comments

@metametadata
Copy link

What would you like to be added:

Scan a single file, e.g. something like grype file:path/to/yourproject/composer.lock.

Why is this needed:

Currently I see only the way to scan the directory recursively: grype dir:path/to/yourproject. But a directory can contain a lot of other stuff which pollutes the output, slows scanning down, etc. E.g. in my project the dir scan detects 3,739 packages vs. 95 specifically from composer.lock due to Ruby and NPM packages detected in subdirs.

@metametadata metametadata added the enhancement New feature or request label Aug 7, 2024
@kzantow
Copy link
Contributor

kzantow commented Sep 16, 2024

Hi @metametadata, Grype supports this today. I've tested this with topthink/framework vulnerability and grype file:path/to/composer.lock successfully showed me the vulnerabilities:

$ grype file:syft/pkg/cataloger/php/test-fixtures/composer.lock 
 ✔ Vulnerability DB                [no update available]  
 ✔ Indexed file system                                                 /Users/kzantow/projects/syft-clean/syft/pkg/cataloger/php/test-fixtures
 ✔ Cataloged contents                                                         6debbc261ba9fb01f4deec7409a8e4e259fc710965d4657e5fdc97c89893bc61
   ├── ✔ Packages                        [2 packages]  
   └── ✔ Executables                     [0 executables]  
 ✔ Scanned for vulnerabilities     [2 vulnerability matches]  
   ├── by severity: 1 critical, 0 high, 1 medium, 0 low, 0 negligible
   └── by status:   1 fixed, 1 not-fixed, 0 ignored 
NAME                INSTALLED  FIXED-IN  TYPE          VULNERABILITY        SEVERITY 
topthink/framework  6.1.3                php-composer  GHSA-f4wh-359g-4pq7  Critical  
topthink/framework  6.1.3      6.1.5     php-composer  GHSA-969f-v7jv-pgj3  Medium

What is the package you are expecting to see vulnerabilities from -- perhaps it's just not in the GHSA data set?

@metametadata
Copy link
Author

Thanks, I simply didn't know there is a file: scheme as it's not mentioned in grype --help or the readme.

@kzantow kzantow added the changelog-ignore Don't include this issue in the release changelog label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-ignore Don't include this issue in the release changelog enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants