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

Sobelow does not detect when secrets are in the test env #164

Open
Adzz opened this issue Apr 25, 2024 · 1 comment
Open

Sobelow does not detect when secrets are in the test env #164

Adzz opened this issue Apr 25, 2024 · 1 comment

Comments

@Adzz
Copy link

Adzz commented Apr 25, 2024

In my runtime.exs file I have:

if config_env() == :test do
  config(:ex_aws, access_key_id: "dummy", secret_access_key: "dummy")
end

There is a check Sobelow.Config.Secrets which says:

  Sobelow detects missing hard-coded secrets by checking the prod
  configuration.

This check fails even though the env is :test. There is also no way to ignore it as far as I can tell? Putting this does not work:

if config_env() == :test do
  # sobelow_skip ["Config.Secrets"]
  config(:ex_aws, access_key_id: "dummy", secret_access_key: "dummy")
end
@houllette
Copy link
Collaborator

Hey @Adzz - sorry you're running into this issue. So that particular check only appears to exclude the config.exs and Sobelow in general has no concept of what mix environment the program is currently being run in (test vs. prod) since it is just statically reading and evaluating code. So as far as Sobelow is concerned, it is parsing the entire runtime.exs file (which is typically used in production) and detecting the fuzzy string search of "secret" and coming back with a finding.

The module documentation is definitely a little vague there by using the "prod" terminology and could probably stand to be improved.

Typically for # sobelow_skip to work, it has to be put on the outside of the offending function - truth be told I don't know off the top of my head how that changes for config files since they're a bit special, but its worth a shot putting the skip before the if statement while i dig into the codebase to see how config skips are handled.

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

No branches or pull requests

2 participants