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

.semgrepignore is not used with absolute paths #9960

Open
sneko opened this issue Mar 18, 2024 · 1 comment
Open

.semgrepignore is not used with absolute paths #9960

sneko opened this issue Mar 18, 2024 · 1 comment
Labels
bug Something isn't working cli Semgrep CLI

Comments

@sneko
Copy link

sneko commented Mar 18, 2024

Hi,

When I'm using:
semgrep --metrics=off --config ./semgrep-rules.yaml .

Everything works as expected, folders into my .semgrepignore are ignored.

But if I use absolute paths, the .semgrepignore seems not considered:
semgrep --metrics=off --config /Users/mynestedfolders/project/semgrep-rules.yaml /Users/mynestedfolders/project/

(note that I tried to used the --project-root parameter from the CLI as specified by semgrep scan --help but it tells me this is no a valid parameter 🤔 )

Thank you,

EDIT: I'm using v1.65.0

@mjambon
Copy link
Member

mjambon commented Mar 25, 2024

It turns out that the current implementation (i.e. not --experimental, more on this later) reads the .semgrepignore` file in the current folder rather than at the project root. I think it wasn't intended this way, so it's a bug.

Now, we have a new implementation of semgrepignore in the works. It is available with --experimental. It follows the gitignore specification more closely and won't have this particular bug. Passing --project-root shouldn't be necessary, it's an option that has been useful for us for internal testing.

Suggested solutions:

  • cd into the project root for the duration of the semgrep job: (cd /Users/mynestedfolders/project/ && semgrep --metrics=off --config ./semgrep-rules.yaml .)
  • or wait for --experimental to become stable or the default (could be a while).

@mjambon mjambon added bug Something isn't working cli Semgrep CLI labels Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Semgrep CLI
Development

No branches or pull requests

2 participants