Repository navigation
Add a parser for agent-evidence-vocabulary terms and their CRE links #1173
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
Open
astrogilda
wants to merge
2
commits into
OWASP:main
Choose a base branch
from
astrogilda-forks:agent-evidence-vocabulary-parser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+669
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from cre_logging import get_logger | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
| import argparse | ||
| import unittest | ||
| from typing import Any | ||
| from unittest.mock import patch | ||
|
|
||
| from application.cmd import cre_main | ||
| from application.utils.external_project_parsers.base_parser import BaseParser | ||
| from application.utils.external_project_parsers.parsers import ( | ||
| agent_evidence_vocabulary, | ||
| ) | ||
|
|
||
|
|
||
| class OnlyFlagsGiven(argparse.Namespace): | ||
| """Answer False for every flag the test does not set.""" | ||
|
|
||
| def __getattr__(self, name: str) -> Any: | ||
| return False | ||
|
|
||
|
|
||
| class TestAgentEvidenceVocabularyCli(unittest.TestCase): | ||
| @patch.object(BaseParser, "register_resource") | ||
| def test_flag_registers_the_parser(self, register_resource) -> None: | ||
| cre_main.run( | ||
| OnlyFlagsGiven(agent_evidence_vocabulary_in=True, cache_file="cache.sqlite") | ||
| ) | ||
| register_resource.assert_called_once_with( | ||
| agent_evidence_vocabulary.AgentEvidenceVocabulary, | ||
| db_connection_str="cache.sqlite", | ||
| ) | ||
|
|
||
| @patch.object(BaseParser, "register_resource") | ||
| def test_parser_does_not_run_without_the_flag(self, register_resource) -> None: | ||
| cre_main.run(OnlyFlagsGiven(cache_file="cache.sqlite")) | ||
| register_resource.assert_not_called() |
Oops, something went wrong.
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.
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.
🎯 Functional Correctness |
Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: OWASP/OpenCRE
Length of output: 11306
🏁 Script executed:
Repository: OWASP/OpenCRE
Length of output: 14434
Import the vocabulary parser for the aggregate shortcut.
When
--import_external_projectsis set without--agent_evidence_vocabulary_in, the new module is not imported.BaseParser.call_importers()discovers only loadedParserInterfacesubclasses, soAgentEvidenceVocabularyis omitted. Import the module whenever either flag is set, while keeping direct registration gated by the individual flag.Suggested fix