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

feat: STFT-57 - Prompt for update on linter version mismatch #3

Merged
merged 11 commits into from
Mar 28, 2023

Conversation

AldosAC
Copy link
Contributor

@AldosAC AldosAC commented Mar 10, 2023

This PR implements a check during a scan which determines if the current configuration is out of date with the configuration SeCureLI expects.

This check will determine there is a mismatch if you modify the .secureli.yaml file, or if the .pre-commit-config.yaml file is modified directly.

If it detects a mismatch, the user will be prompted to update to the expected configuration. If they decline, then the scan will be aborted.

If the mismatch is caused by a linter being added or removed, then SeCureLI will inform the user and indicate which linters were removed, or added unexpectedly.

If the mismatch is caused by a linter version being different, then secureli will notify the user which linter and will indicate which version it expected to find and what version it actually found.

Testing this PR should be fairly straight forward, any change to the .pre-commit-config.yaml file in the root directory will trigger the update request. You can change linter versions, remove linters, or any combination that you like and you should see the prompt to update when you attempt to perform a scan.

Note: There are a bunch of pycache files that are deleted as part of this PR. When this repo was migrated from BitBucket, the .gitignore file was not included, so the cache files were committed. These files should have been ignored, so I removed them while I was working on this PR.

@AldosAC AldosAC changed the title STFT-57: Prompt for update on linter version mismatch feat: STFT-57 - Prompt for update on linter version mismatch Mar 16, 2023
AldosAC and others added 4 commits March 16, 2023 08:44
Also corrects 2 bugs:
- Incorrectly processing case with missing/added linter
and version mismatch at same time
- Moved config validation after upgrade check
@AldosAC AldosAC requested a review from khollerman March 17, 2023 18:17
@centenor
Copy link
Contributor

Prompt works as expected, but it looks like it's returning the same hash? I imagine those two values would be different

image

@AldosAC
Copy link
Contributor Author

AldosAC commented Mar 20, 2023

Great catch, that is absolutely a bug. Let me get that squared away!

@centenor
Copy link
Contributor

If someone manually updates the value in the pre-commit config yaml and then tries to push that update, should this feature block that commit?

@AldosAC
Copy link
Contributor Author

AldosAC commented Mar 20, 2023

No, this doesn't block any commits containing a modified .pre-commit-config.yaml file. It would notify anyone with a modified .pre-commit-config.yaml that the configuration is not what secureli expects though. So if a team member did commit the pre-commit file and other team members pulled that file, they would all receive warnings that the configuration does not match what secureli expects.

@centenor
Copy link
Contributor

Not sure if something changed, but now whenever I run a secureli scan after changing the value of something like black in the .pre-commit-config.yaml nothing gets flagged. Is that intended?

@AldosAC
Copy link
Contributor Author

AldosAC commented Mar 20, 2023

@centenor - Are you still having issues with it detecting changes now?

@AldosAC
Copy link
Contributor Author

AldosAC commented Mar 21, 2023

I spoke with Raul offline and he confirmed the error was the result of using the wrong venv to test and that the application is working as expected.

Copy link

@khollerman khollerman left a comment

Choose a reason for hiding this comment

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

Currently this part of the AC is not being met: "Linter versions can be upgraded OR downgraded."

An acceptance of the update prompt is reverting back to the base version prior to running the scan.

secureli/abstractions/pre_commit.py Outdated Show resolved Hide resolved
secureli/abstractions/pre_commit.py Outdated Show resolved Hide resolved
tests/actions/test_update_action.py Outdated Show resolved Hide resolved
tests/actions/test_update_action.py Outdated Show resolved Hide resolved
Copy link

@khollerman khollerman left a comment

Choose a reason for hiding this comment

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

Looks good

@AldosAC AldosAC changed the title feat: STFT-57 - Prompt for update on linter version mismatch chore: STFT-57 - Prompt for update on linter version mismatch Mar 28, 2023
@AldosAC AldosAC changed the title chore: STFT-57 - Prompt for update on linter version mismatch feat: STFT-57 - Prompt for update on linter version mismatch Mar 28, 2023
@AldosAC AldosAC merged commit 78b353b into main Mar 28, 2023
@AldosAC AldosAC deleted the feature/STFT-057-prompt-linter-update branch March 28, 2023 14:40
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.

3 participants