detect-secrets icon indicating copy to clipboard operation
detect-secrets copied to clipboard

detect-secrets v1.1.0 fails to load any plugins on py38

Open aristotelesneto opened this issue 5 years ago • 13 comments

For some reason on my MacOS (Big Sur, pyenv, python 3.8.8 / 3.9.4) detect-secrets 1.1.0 fails to detect any secret, whereas 1.0.3 seems to work fine.

When using detect-secrets scan with 1.1.0 it returns:

% detect-secrets --version              
1.1.0
% detect-secrets scan
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
[scan]  ERROR   No plugins to scan with!
{
  "version": "1.1.0",
  "plugins_used": [
    {
      "name": "ArtifactoryDetector"
    },
    {
      "name": "AWSKeyDetector"
    },
    {
      "name": "AzureStorageKeyDetector"
    },
    {
      "name": "Base64HighEntropyString",
      "limit": 4.5
    },
    {
      "name": "BasicAuthDetector"
    },
    {
      "name": "CloudantDetector"
    },
    {
      "name": "HexHighEntropyString",
      "limit": 3.0
    },
    {
      "name": "IbmCloudIamDetector"
    },
    {
      "name": "IbmCosHmacDetector"
    },
    {
      "name": "JwtTokenDetector"
    },
    {
      "name": "KeywordDetector",
      "keyword_exclude": ""
    },
    {
      "name": "MailchimpDetector"
    },
    {
      "name": "NpmDetector"
    },
    {
      "name": "PrivateKeyDetector"
    },
    {
      "name": "SlackDetector"
    },
    {
      "name": "SoftlayerDetector"
    },
    {
      "name": "SquareOAuthDetector"
    },
    {
      "name": "StripeDetector"
    },
    {
      "name": "TwilioKeyDetector"
    }
  ],
  "filters_used": [
    {
      "path": "detect_secrets.filters.allowlist.is_line_allowlisted"
    },
    {
      "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
      "min_level": 2
    },
    {
      "path": "detect_secrets.filters.heuristic.is_indirect_reference"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_likely_id_string"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_lock_file"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_potential_uuid"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_sequential_string"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_swagger_file"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_templated_secret"
    }
  ],
  "results": {},
  "generated_at": "2021-04-16T00:24:54Z"
}

% detect-secrets scan --list-all-plugins
ArtifactoryDetector
AWSKeyDetector
AzureStorageKeyDetector
BasicAuthDetector
CloudantDetector
Base64HighEntropyString
HexHighEntropyString
IbmCloudIamDetector
IbmCosHmacDetector
JwtTokenDetector
KeywordDetector
MailchimpDetector
NpmDetector
PrivateKeyDetector
SlackDetector
SoftlayerDetector
SquareOAuthDetector
StripeDetector
TwilioKeyDetector

If I switch to Python 3.7.9 (or revert back to 1.0.3) it seems to work correctly.

% detect-secrets --version         
1.0.3
% detect-secrets scan     
{
  "version": "1.0.3",
  "plugins_used": [
    {
      "name": "ArtifactoryDetector"
    },
    {
      "name": "AWSKeyDetector"
    },
    {
      "name": "AzureStorageKeyDetector"
    },
    {
      "name": "Base64HighEntropyString",
      "limit": 4.5
    },
    {
      "name": "BasicAuthDetector"
    },
    {
      "name": "CloudantDetector"
    },
    {
      "name": "HexHighEntropyString",
      "limit": 3.0
    },
    {
      "name": "IbmCloudIamDetector"
    },
    {
      "name": "IbmCosHmacDetector"
    },
    {
      "name": "JwtTokenDetector"
    },
    {
      "name": "KeywordDetector",
      "keyword_exclude": ""
    },
    {
      "name": "MailchimpDetector"
    },
    {
      "name": "NpmDetector"
    },
    {
      "name": "PrivateKeyDetector"
    },
    {
      "name": "SlackDetector"
    },
    {
      "name": "SoftlayerDetector"
    },
    {
      "name": "SquareOAuthDetector"
    },
    {
      "name": "StripeDetector"
    },
    {
      "name": "TwilioKeyDetector"
    }
  ],
  "filters_used": [
    {
      "path": "detect_secrets.filters.allowlist.is_line_allowlisted"
    },
    {
      "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
      "min_level": 2
    },
    {
      "path": "detect_secrets.filters.heuristic.is_indirect_reference"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_likely_id_string"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_potential_uuid"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_sequential_string"
    },
    {
      "path": "detect_secrets.filters.heuristic.is_templated_secret"
    }
  ],
  "results": {
    "tests/conftest.py": [
      {
        "type": "Secret Keyword",
        "filename": "tests/conftest.py",
        "hashed_secret": "dc724af18fbdd4e59189f5fe768a5f8311527050",
        "is_verified": false,
        "line_number": 50
      }
    ]
  },
  "generated_at": "2021-04-16T00:26:42Z"
}

% detect-secrets scan --list-all-plugins
ArtifactoryDetector
AWSKeyDetector
AzureStorageKeyDetector
BasicAuthDetector
CloudantDetector
Base64HighEntropyString
HexHighEntropyString
IbmCloudIamDetector
IbmCosHmacDetector
JwtTokenDetector
KeywordDetector
MailchimpDetector
NpmDetector
PrivateKeyDetector
SlackDetector
SoftlayerDetector
SquareOAuthDetector
StripeDetector

aristotelesneto avatar Apr 16 '21 00:04 aristotelesneto

Super interesting problem.

I took a quick look, and it turns out that the issue is with the changes that Python3.8 introduced to the multiprocessing library. I hypothesize that Python3.8 doesn't share memory between processors by default, which means that the global settings object becomes inaccessible across processors: https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/core/secrets_collection.py#L58-L64

If you downgrade to Python3.7, you should be able to run this on v1.1.

domanchi avatar Apr 16 '21 03:04 domanchi

I can confirm running on v1.1 works correctly on python 3.7.9. Interestingly, on an Azure DevOps pipeline running Python 3.8 (ubuntu-latest [20.04] agent, ms hosted) detect-secrets v1.1 correctly finds secrets (but because we couldn't baseline it, it meant it was failing our build). Is there some more data you'd like me to capture myself to be able address this issue or were you able to reproduce?

aristotelesneto avatar Apr 16 '21 08:04 aristotelesneto

Weeird.

I was able to reproduce this on MacOS Catalina, pyenv, 3.8.5. And if my hypothesis is correct, you won't encounter this issue if you try scanning one file, since I wrote a bypass for that case: https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/core/secrets_collection.py#L51-L53.

Could you verify that?

domanchi avatar Apr 16 '21 13:04 domanchi

getting the same issue on windows 10

s1mrankaur avatar Apr 16 '21 22:04 s1mrankaur

To add to this, can confirm the same behavior on Windows 10 using Python 3.7.9. image

As mentioned above scanning an individual file completes successfully and returns good results, as well as downgrading to version 1.0.3 doesn't have the issue

YustinS avatar Apr 20 '21 00:04 YustinS

Spent lot of time on this issue before coming across this ticket... downgrading to 1.0.3. works for me

DenysVuika avatar May 12 '21 15:05 DenysVuika

It happens to me programmatically with the pypi package. When using solely scan_file() like below I get "[scan] ERROR No plugins to scan with!" :

...
for file in files:
    secrets.scan_file(file)
...

But when using with default_settings() everything works fine :

...
with default_settings():
    for file in files:
        secrets.scan_file(file)
...

default setting() enables all filters and plugins by default. So I can suggest to enable all plugins on the command line:

> detect-secrets scan --force-use-all-plugins

PS: I have not tested the cli solution.

Versions used :

> python3 --version
Python 3.8.6
> detect-secrets --version
1.1.0

shadawck avatar May 30 '21 18:05 shadawck

Same problem on Windows 10.

> python -V
Python 3.8.0
> detect-secrets --version
1.1.0

Resolved by downgrading to previous release (1.0.3), for now:

> pip uninstall detect-secrets
Found existing installation: detect-secrets 1.1.0
Uninstalling detect-secrets-1.1.0:
...
Successfully uninstalled detect-secrets-1.1.0
> pip install detect-secrets==1.0.3

edthedev avatar Jul 07 '21 16:07 edthedev

@domanchi wrote:

I was able to reproduce this on MacOS Catalina, pyenv, 3.8.5. And if my hypothesis is correct, you won't encounter this issue if you try scanning one file, since I wrote a bypass for that case: https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/core/secrets_collection.py#L51-L53.

Could you verify that?

Verified. Scanning a folder with python -m detect_secrets scan test_data with Python 3.8 gets the "No plugins to scan with!" error, while scanning a single file with python -m detect_secrets scan test_data/config.ini works.

gpflaum avatar Aug 28 '21 00:08 gpflaum

@shadawck suggested trying --force-use-all-plugins. That didn't work, still get the "No plugins to scan with!" error.

gpflaum avatar Aug 28 '21 01:08 gpflaum

@domanchi wrote:

I was able to reproduce this on MacOS Catalina, pyenv, 3.8.5. And if my hypothesis is correct, you won't encounter this issue if you try scanning one file, since I wrote a bypass for that case: https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/core/secrets_collection.py#L51-L53. Could you verify that?

Verified. Scanning a folder with python -m detect_secrets scan test_data with Python 3.8 gets the "No plugins to scan with!" error, while scanning a single file with python -m detect_secrets scan test_data/config.ini works.

Same here using v1.1.0 installed through homebrew on MacOS with python3 --version at 3.9.7. Scanning the individual file was successful while all other run modes I tried fail.

agemooij avatar Oct 07 '21 09:10 agemooij

Any update on this issue? I'd like to leverage the latest features in v1.1.0 but this is a blocking issue for me. Able to repro on Windows 10/11 with Python 3.7+

wbreza avatar Jan 12 '22 23:01 wbreza

I'm also willing to help test when this is resolved, as I believe I still have an organizational 'how-to' document that has a pinned version that I would love to see un-pinned.

edthedev avatar Jan 14 '22 18:01 edthedev