-
Notifications
You must be signed in to change notification settings - Fork 278
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
Update sign.py to only sign specific file types #303
Conversation
Perfect opportunity for a unit test ;) |
bundle-workflow/python/sign.py
Outdated
artifact_list = component.artifacts[artifact_type] | ||
|
||
artifact_list = [a for a in component.artifacts[artifact_type] if pathlib.Path(a).suffix in ACCEPTED_FILE_TYPES] |
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.
Might be useful for debugging to know what was excluded with a log message
1cb8efb
to
c33b3df
Compare
Signed-off-by: Marc Handalian <handalm@amazon.com>
import sys | ||
|
||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../..")) | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../src")) |
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.
idk if there is a more elegant way to define this, but without /src it could not find the signer's import of git_repository.
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.
I couldn't find a better way to do it.
You should have just one though, and in tests import from src.git.git_repository import GitRepository
, note the src.
. As written you may have a conflict in class names between tests
and src
.
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.
Hmm, I tried this but still get a module not found error with pytest.
bundle-workflow/src/signing_workflow/signer.py:10: in <module>
from git.git_repository import GitRepository
E ModuleNotFoundError: No module named 'git'
The signer.py src file has a dependency on GitRepository, and when running tests it can't find git.git_repository on the path unless I explicitly add the extra
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../src"))
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.
going to merge as is, will see if I can sort this out.
|
||
class TestSigner(unittest.TestCase): | ||
|
||
@patch('src.signing_workflow.signer.GitRepository') |
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.
Oh I like this!
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.
I think you should fix the double insert of paths in __init__.py
, otherwise LGTM.
Signed-off-by: Marc Handalian <handalm@amazon.com>
Signed-off-by: Marc Handalian handalm@amazon.com
Description
Restrict signer to sign only the following file types - ['.zip', '.jar', '.war', '.pom', '.module', 'tar.gz']
Issues Resolved
closes #302
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.