Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fix: add support for pyproject.toml and env.yml/env.yaml files #550
fix: add support for pyproject.toml and env.yml/env.yaml files #550
Changes from 8 commits
9bb547a
4c46b28
333421d
958a39e
42790a2
3630e88
0684758
db257de
0544d7c
bc06211
8748d5b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve dependency parsing to handle various version specifiers
The current approach splits the dependency string on
'=='
to obtaindep_name
anddep_version
. This may not correctly handle dependencies with different version specifiers (e.g.,'>='
,'~='
,'!='
) or additional markers and extras. Consider using a robust parser, such aspackaging.requirements.Requirement
, to accurately parse dependency strings.Apply this diff to parse dependencies using the
packaging
library:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider refactoring special files handling into a dedicated handler.
The current implementation duplicates logic and reduces maintainability. Consider these improvements:
SpecialFileHandler
class that implements theFileHandler
interfaceExample implementation:
This approach would:
💡 Codebase verification
Based on the search results, I can now generate a final response.
The ecosystem handlers need to be updated for the new file types
The search results reveal that while
pyproject.toml
and environment files (env.yml
,env.yaml
) are added to the special files list infile_finder.py
, there are gaps in the implementation:FileType
enum is used in multiple places butpyproject.toml
and environment files are not included in theDEFAULT_FILE_TYPES
list inscan/command.py
pyproject.toml
inecosystems/python/dependencies.py
(read_pyproject_toml_dependencies
), there's no handler for environment filesSUPPORTED_FILE_TYPES
insafety.py
) need to be updated if these files should support remediationRequired updates:
DEFAULT_FILE_TYPES
list if they should be scanned by defaultSUPPORTED_FILE_TYPES
if fixes should be supported for these file types🔗 Analysis chain
Verify related ecosystem handlers are updated.
The implementation adds support for
pyproject.toml
and environment files, but we should verify that corresponding handlers in the ecosystem mapping can process these files correctly.Let me try a different search strategy to verify the ecosystem handlers.
Let me try one final search strategy focusing on the FileType enum and its usage.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 336
Script:
Length of output: 514
Script:
Length of output: 4851