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

Pre-receive hook support in Github enterprise #181

Open
roshvin opened this issue May 6, 2024 · 2 comments
Open

Pre-receive hook support in Github enterprise #181

roshvin opened this issue May 6, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed integration Related to integration with other systems

Comments

@roshvin
Copy link

roshvin commented May 6, 2024

Describe the bug
Pre-receive hook support in Github enterprise

Hi,

is there any option or example where we can use this as a pre-receive hook at Github Enterprise server.

Thanks

@roshvin roshvin added the bug Something isn't working label May 6, 2024
@bradlarsen bradlarsen added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels May 7, 2024
@bradlarsen
Copy link
Collaborator

Hi @roshvin, and thanks for the question.

I'm not aware of any example at present for using Nosey Parker in a pre-receive hook for GitHub Enterprise Server. (Presumably the use case there is to be able to scan for secrets at push time, and block pushing of commits that contain secrets.)

To make that work, you'd need to script some pieces: in a pre-receive hook, run noseyparker scan on the received content, and then perhaps noseyparker report -f json, followed by some test in the pre-receive hook that would cause it to fail if there were any Nosey Parker findings in the JSON output. I've not written such a thing myself.

One thing you would want to do if you set up a mechanism like this is specify a custom ruleset to only enable rules that have essentially no false positives, as you don't want to spuriously be blocking developer's commits. This mechanism is not well documented, but it involves writing a YAML file with the list of rule IDs that you want to enable, and then invoking noseyparker scan --rules-path YOUR_YAML_FILE --ruleset YOUR_RULESET_NAME.

See here for an example ruleset: https://github.com/praetorian-inc/noseyparker/blob/0cce95910be38058cc0cf00b548a892e3ed5dc35/crates/noseyparker/data/default/builtin/rulesets/default.yml

Let me know if you have questions about this and I will write up more documentation.

@roshvin
Copy link
Author

roshvin commented May 8, 2024

Hi @bradlarsen thanks a lot for the quick help/support.

@bradlarsen bradlarsen added the integration Related to integration with other systems label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed integration Related to integration with other systems
Projects
None yet
Development

No branches or pull requests

2 participants