-
Notifications
You must be signed in to change notification settings - Fork 22
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
chore: pre-commit secrets scanner #1170
Conversation
scripts/utils/git-secrets.js
Outdated
const { error: errorAddProvider, stdout: stdoutAddProvider, stderr: stderrAddProvider } = shell.exec( | ||
`git secrets --add-provider -- git secrets --aws-provider ${TEMP_CRED_FILE}`, | ||
{ | ||
stdio: 'inherit', | ||
}, | ||
) | ||
if (errorAddProvider) throw errorAddProvider | ||
if (stderrAddProvider) throw stderrAddProvider | ||
console.log('Added AWS provider\n', stdoutAddProvider) | ||
|
||
// scan for secrets | ||
const { error: errorScan, stdout: stdoutScan, stderr: stderrScan } = shell.exec('git secrets --scan --cached', { | ||
stdio: 'inherit', | ||
}) | ||
if (errorScan) throw errorScan | ||
if (stderrScan) throw stderrScan | ||
console.log('No secrets found in staged files!\n', stdoutScan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to chain these two commands using &&, but it doesn't work as expected, need to separate into two commands
chore: update comment
017fd7f
to
eb65b84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thankyou 👍
removeTempCredFile() | ||
} catch (err) { | ||
console.error(err) | ||
removeTempCredFile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thinks this part could result unhandled error if unlinksync
is fail to execute and throws error
LGTM. Nice 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if it throws an error, then just let it does, the script will auto exit with an error code.
If all things go well, then no error is returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me i don't use aws credential file, only use bash profile, are there any way to check it ?
@tanphamhaiduong I've already checked both authentication mechanisms. If you use bash profile, it means you're exporting Just updated comment on that function to avoid confusing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add pre-commit hook to scan for secrets before commit
FLOW:
~/.aws/credentials
git secrets --scan