-
Notifications
You must be signed in to change notification settings - Fork 97
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
Refinement: Removed Redundancy of Scan Config Passing #304
Refinement: Removed Redundancy of Scan Config Passing #304
Conversation
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.
Thanks for your PR. I left some suggestions. PTAL.
src/gcp_scanner/scanner.py
Outdated
@@ -180,8 +180,10 @@ def get_crawl( | |||
Returns: | |||
scan_result: a dictionary with scanning results | |||
""" | |||
|
|||
res = crawler.crawl(project_id, client, crawler_config) | |||
if crawler.crawler_config: |
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.
You are not actually calling the function here. This statement will always return true.
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.
If you are referencing about the crawler_config not having parentheses denoting a function, it is because the crawler_config method is a property, and properties in Python are typically accessed without parentheses.
The above testing image shows that, when the scanner is run, it is not always giving true for crawler_config. False for every class except of StorageBucketsCrawler
(As for now only that class needs the config file).
Please let me know, if I have misunderstood your comment or something else was wrong.
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 my bad, right. NVM. I'd rename the function to make it more clear of what is this property about. Right now we have too many crawler_config
s in the code.
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.
Yes, fair point. I have made the changes, changed the name to has_config_dependency
from crawler_config
Thank you for going through my PR, and reviewing it. I think, I have done the relevant changes as asked. Please let me know in case any others are needed. |
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.
One small suggestion and we are good to go.
src/gcp_scanner/scanner.py
Outdated
@@ -180,8 +180,10 @@ def get_crawl( | |||
Returns: | |||
scan_result: a dictionary with scanning results | |||
""" | |||
|
|||
res = crawler.crawl(project_id, client, crawler_config) | |||
if crawler.crawler_config: |
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 my bad, right. NVM. I'd rename the function to make it more clear of what is this property about. Right now we have too many crawler_config
s in the code.
Pushed with the changes 😁 |
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.
Thanks for the fix!
Fixes #241
Description
crawler_config
in base classICrawler
which is returns bool value, wheredefault=False
crawler_config
in the base class needs to be overridden in the sub class to return True.Note : Currently as I was checking all the crawlers, I have just seen that config is being used only inside the
StorageBucketsCrawler
crawler. So only its value is set as True in its base class.Changes Made
ICrawler
has a new property called ascrawler_config
which returns the abstracted private variable_config_depndency
which is set to False by default.StorageBucketsCrawler
class has overriddencrawler_config
to return True.get_crawl
function in scanner.py has a check now calling thecrawler_config
to decide to send config or not.Testing
Local testing done with logs denoting that where config file is sent and where it is not. (Removed the logs after the testing)
This check denotes that only
StorageBucketsCrawler
is being sent the config file