Skip to content

Conversation

sean-roberts
Copy link
Contributor

🎉 Thanks for submitting a pull request! 🎉

Summary

Support for globs support for secrets scanning. Requested by enterprise team: https://netlify.slack.com/archives/C023PC3D08J/p1713347068392949

Fixes https://linear.app/netlify/issue/COM-665/glob-support-in-secrets-scan-omit-paths


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@sean-roberts sean-roberts self-assigned this Apr 17, 2024
@sean-roberts sean-roberts requested review from a team as code owners April 17, 2024 15:23
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

Secret env var "ENV_VAR_2"'s value detected:␊
found value at line 1 in dist/static-files/notsafefile.js␊
found value at line 1 in src/static-files/notsafefile.js␊
Copy link
Contributor Author

Choose a reason for hiding this comment

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

context: the tests omit our globbed path but not the file next to it by design.

const omitPathMatches = (relativePath, omitPaths) => {
return omitPaths.some((oPath) => {
// check if the substring matches or glob pattern
return relativePath.startsWith(oPath) || minimatch(relativePath, oPath, { dot: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the actual change is using minimatch for globs in addition to substring support

@Skn0tt
Copy link
Contributor

Skn0tt commented Apr 17, 2024

The change itself looks good. I'm wondering if there's a different matching library we could use that's already part of the dependencies, so we don't increase bundlesize unneccessarily.

Copy link
Contributor

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

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

In zip-it-and-ship-it, which is a dep of build, we're using fast-glob for matching:

https://github.com/netlify/zip-it-and-ship-it/blob/a2071a6e606cc1434fa9d556306bd9dbc7cd7943/package.json#L68C5-L68C27

Could we also use that in here, to save on some bundle size?

@sean-roberts
Copy link
Contributor Author

sean-roberts commented Apr 17, 2024

@Skn0tt I used minimatch because it's used in the build-info package

@Skn0tt
Copy link
Contributor

Skn0tt commented Apr 17, 2024

Oh, good point! I still think we should concentrate on one, but that's a separate issue then :D

Skn0tt
Skn0tt previously approved these changes Apr 17, 2024
@sean-roberts
Copy link
Contributor Author

Agreed!

@sean-roberts sean-roberts changed the title Sr/globby mcglobface feat(secrets scanning): support globs Apr 17, 2024
@sean-roberts sean-roberts merged commit c5c79df into main Apr 17, 2024
@sean-roberts sean-roberts deleted the sr/globby-mcglobface branch April 17, 2024 16:03
This was referenced Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants