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

Add pre-commit hooks to catch linting issues and prevent credential leaks #2069

Closed
varunsh-coder opened this issue Apr 10, 2023 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@varunsh-coder
Copy link
Member

https://github.com/pre-commit/pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.

It is very popular, and one of the important use cases is to detect and prevent credentials from being pushed. This is important because the cost of dealing with a cred leak is much higher once it is already pushed.

Using a PR, we should add a pre-commit configuration .pre-commit-config.yaml as a best practice. If the file already exists, then we should suggest adding specific hooks related to security.

Here is an example of such a file
https://github.com/aws-samples/aws-deployment-pipeline-reference-architecture/blob/1329e3cb20f3ef782fca907ddce39d94a8b4c813/examples/cdk-application-pipeline/.pre-commit-config.yaml

@varunsh-coder varunsh-coder added the enhancement New feature or request label Apr 10, 2023
@varunsh-coder
Copy link
Member Author

@Devils-Knight please take this up

@varunsh-coder
Copy link
Member Author

What hooks should we be recommending for linting and for credential scanning?

For credential scanning, the options are gitleaks, trufflehog, and we should try to find more.

For linting, there are some basic non-language-specific options like trailing-whitespace, and then there might be others specific to programming languages like check-yaml.

@WikiRik
Copy link

WikiRik commented Apr 12, 2023

Would it be possible to use other libraries as well that do similar things with commit hooks? Mainly https://github.com/typicode/husky

@varunsh-coder
Copy link
Member Author

Would it be possible to use other libraries as well that do similar things with commit hooks? Mainly https://github.com/typicode/husky

Thanks a lot for sharing @WikiRik! I did not know about husky and will read more about it.

@varunsh-coder
Copy link
Member Author

This is done and released. https://app.stepsecurity.io/securerepo now shows an option to add pre-commit hooks.

Screen Shot 2023-07-04 at 9 26 45 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants