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

Enable S rule #1857

Merged
merged 7 commits into from
Nov 6, 2023
Merged

Enable S rule #1857

merged 7 commits into from
Nov 6, 2023

Conversation

artem-shelkovnikov
Copy link
Member

Slightly controversial potentially rule:

Enabling "S" rule for linter: https://pypi.org/project/flake8-bandit/

There are a lot of subrules, but generally this group is about security-related issues.

Reported problems:

connectors/sources/directory.py:60:16: S324 Probable use of insecure hash functions in `hashlib`: `md5`
connectors/sources/dropbox.py:67:20: S105 Possible hardcoded password assigned to: "ACCESS_TOKEN"
connectors/sources/microsoft_teams.py:63:31: S105 Possible hardcoded password assigned to: "GRAPH_ACQUIRE_TOKEN_URL"
connectors/sources/mssql.py:56:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mssql.py:60:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mssql.py:64:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mssql.py:68:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mssql.py:72:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:57:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:60:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:63:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:66:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:69:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/mysql.py:474:38: S608 Possible SQL injection vector through string-based query construction
connectors/sources/oracle.py:42:13: S608 Possible SQL injection vector through string-based query construction
connectors/sources/oracle.py:47:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/oracle.py:51:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/oracle.py:55:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/oracle.py:59:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/outlook.py:620:17: S112 `try`-`except`-`continue` detected, consider logging the exception
connectors/sources/postgresql.py:52:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/postgresql.py:57:13: S608 Possible SQL injection vector through string-based query construction
connectors/sources/postgresql.py:64:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/postgresql.py:68:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/postgresql.py:72:16: S608 Possible SQL injection vector through string-based query construction
connectors/sources/s3.py:193:18: S324 Probable use of insecure hash functions in `hashlib`: `md5`
connectors/sources/salesforce.py:32:18: S105 Possible hardcoded password assigned to: "TOKEN_ENDPOINT"
connectors/utils.py:220:36: S602 `subprocess` call with `shell=True` identified, security issue
connectors/utils.py:418:9: S110 `try`-`except`-`pass` detected, consider logging the exception
connectors/utils.py:641:12: S324 Probable use of insecure hash functions in `hashlib`: `md5`

All SQL-reported problems will be investigated and fixed later, thus I've added an ignore rule for now, all others I've manually checked and marked as non-problem.

For now I've also ignored it in test files, manually checking them, but would like to discuss it further - to me it makes sense to enable it for tests too, so that if some credentials are leaked by accident, then the linter will complain.

@@ -29,7 +29,7 @@

BASE_URL = "https://<domain>.my.salesforce.com"
API_VERSION = "v58.0"
TOKEN_ENDPOINT = "/services/oauth2/token"
TOKEN_ENDPOINT = "/services/oauth2/token" # noqa S105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wild that it thinks this is a password 🤷🏻

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think the word "TOKEN" triggered it

@@ -128,6 +127,28 @@ async def _start_service(actions, config, loop):
return await multiservice.run()


def get_event_loop(uvloop=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why did get_event_loop have to be moved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause it had a "try/except" with except that does nothing. I've added a logger statement there and moved to the only place where the function is used

@navarone-feekery
Copy link
Contributor

For now I've also ignored it in test files, manually checking them, but would like to discuss it further - to me it makes sense to enable it for tests too, so that if some credentials are leaked by accident, then the linter will complain.

I agree having this on for tests makes sense. If it ends up raising too many false positives then we can always disable it.

@artem-shelkovnikov artem-shelkovnikov merged commit b53220a into main Nov 6, 2023
@artem-shelkovnikov artem-shelkovnikov deleted the artem/enable-s-linter-rule branch November 6, 2023 12:11
Copy link

github-actions bot commented Nov 6, 2023

💔 Failed to create backport PR(s)

The backport operation could not be completed due to the following error:
There are no branches to backport to. Aborting.

The backport PRs will be merged automatically after passing CI.

To backport manually run:
backport --pr 1857 --autoMerge --autoMergeMethod squash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants