Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dakranj_add_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdakran committed Feb 2, 2022
2 parents 00816f9 + 75a5844 commit 0fbd117
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python: ['3.6', '3.7', '3.8', '3.9']
python: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
20 changes: 16 additions & 4 deletions detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from . import scan
from .potential_secret import PotentialSecret
from detect_secrets.settings import configure_settings_from_baseline
from detect_secrets.settings import get_settings


class PatchedFile:
Expand Down Expand Up @@ -55,7 +57,13 @@ def scan_files(self, *filenames: str, num_processors: Optional[int] = None) -> N
if not num_processors:
num_processors = mp.cpu_count()

with mp.Pool(processes=num_processors) as p:
child_process_settings = get_settings().json()

with mp.Pool(
processes=num_processors,
initializer=configure_settings_from_baseline,
initargs=(child_process_settings,),
) as p:
for secrets in p.imap_unordered(
_scan_file_and_serialize,
[os.path.join(self.root, filename) for filename in filenames],
Expand Down Expand Up @@ -241,8 +249,12 @@ def __eq__(self, other: Any, strict: bool = False) -> bool:
return False

for filename in self.files:
self_mapping = {secret.secret_hash: secret for secret in self[filename]}
other_mapping = {secret.secret_hash: secret for secret in other[filename]}
self_mapping = {
(secret.secret_hash, secret.type): secret for secret in self[filename]
}
other_mapping = {
(secret.secret_hash, secret.type): secret for secret in other[filename]
}

# Since PotentialSecret is hashable, we compare their identities through this.
if set(self_mapping.values()) != set(other_mapping.values()):
Expand All @@ -252,7 +264,7 @@ def __eq__(self, other: Any, strict: bool = False) -> bool:
continue

for secretA in self_mapping.values():
secretB = other_mapping[secretA.secret_hash]
secretB = other_mapping[(secretA.secret_hash, secretA.type)]

valuesA = vars(secretA)
valuesA.pop('secret_value')
Expand Down

0 comments on commit 0fbd117

Please sign in to comment.