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

fix: correct bandit path and activate flake8 #159

Merged
merged 1 commit into from
Dec 5, 2021
Merged

Conversation

shawaj
Copy link
Member

@shawaj shawaj commented Dec 4, 2021

Issue

How

  • fix bandit path
  • activate flake8
  • fix flake8 errors
  • fix bandit errors
  • add .github/linters/.flake8 config file with 120 character limit
  • exclude generated protos with _pb2.py file ending
  • change to super linter slim version, for quicker linting
  • remove f string from logging.Formatter as per https://docs.python.org/3/howto/logging-cookbook.html
  • change bare except to except Exception:
  • correct unit test path for gatewayconfig
  • add minimum unit test coverage of 70%

Screenshots

image

References

Relates-to: #140
Original lint logs - https://github.com/NebraLtd/hm-config/runs/4418032109?check_suite_focus=true and at logs_2850.zip

Checklist

  • Tests added
  • Cleaned up commit history (rebase!)
  • Documentation added
  • Thought about variable and method names

@shawaj
Copy link
Member Author

shawaj commented Dec 4, 2021

Bandit test results:

Test results:
>> Issue: [B110:try_except_pass] Try, Except, Pass detected.
   Severity: Low   Confidence: High
   Location: ./gatewayconfig/bluetooth/characteristics/wifi_connect_characteristic.py:74:12
   More Info: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html
73	                self.connect_to_wifi(self.wifi_service, self.wifi_password)
74	            except Exception:
75	                pass
76	

--------------------------------------------------
>> Issue: [B105:hardcoded_password_string] Possible hardcoded password: 'invalid'
   Severity: Low   Confidence: Medium
   Location: ./gatewayconfig/constants.py:96:24
   More Info: https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html
95	WIFI_ERROR = "error"
96	WIFI_INVALID_PASSWORD = "invalid"
97	
98	# WiFi Status Mapping
99	WIFI_STATUSES = {

--------------------------------------------------

Have ignored the B105 error as this is a false positive.

For the B101 error I changed the code in question to:

        if self.wifi_service and self.wifi_password:
            try:
                self.connect_to_wifi(self.wifi_service, self.wifi_password)
            except Exception:
                logger.exception("Wifi connect failed for unknown reason")

@shawaj shawaj changed the title fix: correct bandit path fix: correct bandit path and activate flake8 Dec 4, 2021
@shawaj shawaj marked this pull request as ready for review December 4, 2021 20:21
@shawaj shawaj requested a review from a team as a code owner December 4, 2021 20:21
- fix bandit path
- activate flake8
- fix flake8 errors
- fix bandit errors
- add .github/linters/.flake8 config file with 120 character limit
- exclude generated protos with _pb2.py file ending
- change to super linter slim version, for quicker linting
- remove f string from logging.Formatter as per https://docs.python.org/3/howto/logging-cookbook.html
- change bare except to except Exception:
- correct unit test path for gatewayconfig
- bump minimum unit test percentage requirement to 70%

Relates-to: #140
@shawaj shawaj merged commit c6caddf into master Dec 5, 2021
@shawaj shawaj deleted the shawaj/bandito branch December 5, 2021 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants