-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[no ci] Merge remote-tracking branch 'upstream/main' into pydriller
- Loading branch information
Showing
59 changed files
with
4,676 additions
and
6,475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
DATA: 19434458 valid lines. MARKUP: 74639 items | ||
DATA: 19434458 valid lines. MARKUP: 74402 items | ||
Category Positives Negatives Template | ||
-------------------------- ----------- ----------- ---------- | ||
Authentication Key & Token 70 1 31 | ||
Generic Secret 1056 15 203 | ||
Generic Token 333 45 558 | ||
Other 1076 63510 635 | ||
Other 839 63510 635 | ||
Password 1405 110 4170 | ||
Predefined Pattern 326 2 40 | ||
Private Key 1001 1 3 | ||
Seed, Salt, Nonce 40 4 4 | ||
TOTAL: 5307 63688 5644 | ||
Detected Credentials: 5996 | ||
credsweeper result_cnt : 5338, lost_cnt : 0, true_cnt : 4441, false_cnt : 897 | ||
TOTAL: 5070 63688 5644 | ||
Detected Credentials: 5730 | ||
credsweeper result_cnt : 5102, lost_cnt : 0, true_cnt : 4207, false_cnt : 895 | ||
Category TP FP TN FN FPR FNR ACC PRC RCL F1 | ||
-------------------------- ---- ---- -------- ---- --------- --------- -------- -------- -------- -------- | ||
Authentication Key & Token 54 4 28 16 0.125 0.228571 0.803922 0.931034 0.771429 0.84375 | ||
Generic Secret 973 3 215 83 0.0137615 0.0785985 0.932496 0.996926 0.921402 0.957677 | ||
Generic Token 289 7 596 44 0.0116086 0.132132 0.945513 0.976351 0.867868 0.918919 | ||
Other 818 749 63396 258 0.0116767 0.239777 0.98456 0.522017 0.760223 0.618994 | ||
Other 584 747 63398 255 0.0116455 0.303933 0.984581 0.438768 0.696067 0.538249 | ||
Password 995 130 4150 410 0.0303738 0.291815 0.905013 0.884444 0.708185 0.786561 | ||
Predefined Pattern 309 2 40 17 0.0476191 0.0521472 0.94837 0.993569 0.947853 0.970173 | ||
Private Key 967 0 4 34 0.033966 0.966169 1 0.966034 0.982724 | ||
Seed, Salt, Nonce 36 2 6 4 0.25 0.1 0.875 0.947368 0.9 0.923077 | ||
4441 897 19428254 866 4.617e-05 0.163181 0.999909 0.83196 0.836819 0.834382 | ||
4207 895 19428493 863 4.606e-05 0.170217 0.99991 0.824579 0.829783 0.827173 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ | |
'__version__' | ||
] | ||
|
||
__version__ = "1.5.9" | ||
__version__ = "1.5.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import email | ||
import logging | ||
from abc import ABC | ||
from typing import List | ||
|
||
from credsweeper.credentials import Candidate | ||
from credsweeper.deep_scanner.abstract_scanner import AbstractScanner | ||
from credsweeper.file_handler.byte_content_provider import ByteContentProvider | ||
from credsweeper.file_handler.data_content_provider import DataContentProvider | ||
from credsweeper.file_handler.string_content_provider import StringContentProvider | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class EmlScanner(AbstractScanner, ABC): | ||
"""Implements eml scanning""" | ||
|
||
def data_scan( | ||
self, # | ||
data_provider: DataContentProvider, # | ||
depth: int, # | ||
recursive_limit_size: int) -> List[Candidate]: | ||
"""Tries to scan EML with text representation""" | ||
candidates = [] | ||
|
||
try: | ||
msg = email.message_from_bytes(data_provider.data) | ||
for part in msg.walk(): | ||
content_type = part.get_content_type() | ||
body = part.get_payload(decode=True) | ||
|
||
if "text/plain" == content_type: | ||
eml_text_data_provider = ByteContentProvider(content=body, | ||
file_path=data_provider.file_path, | ||
file_type=data_provider.file_type, | ||
info=f"{data_provider.info}|EML-TEXT") | ||
eml_candidates = self.scanner.scan(eml_text_data_provider) | ||
candidates.extend(eml_candidates) | ||
elif "text/html" == content_type: | ||
html_data_provider = DataContentProvider(data=body) | ||
if html_data_provider.represent_as_html(depth, recursive_limit_size, | ||
self.scanner.keywords_required_substrings_check): | ||
string_data_provider = StringContentProvider(lines=html_data_provider.lines, | ||
line_numbers=html_data_provider.line_numbers, | ||
file_path=data_provider.file_path, | ||
file_type=data_provider.file_type, | ||
info=f"{data_provider.info}|EML-HTML") | ||
html_candidates = self.scanner.scan(string_data_provider) | ||
candidates.extend(html_candidates) | ||
except Exception as eml_exc: | ||
logger.error(f"{data_provider.file_path}:{eml_exc}") | ||
return candidates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import binascii | ||
import contextlib | ||
|
||
import base62 | ||
|
||
from credsweeper.common.constants import ASCII | ||
from credsweeper.config import Config | ||
from credsweeper.credentials import LineData | ||
from credsweeper.file_handler.analysis_target import AnalysisTarget | ||
from credsweeper.filters import Filter | ||
|
||
|
||
class ValueGitHubCheck(Filter): | ||
"""GitHub Classic Token validation""" | ||
|
||
def __init__(self, config: Config = None) -> None: | ||
pass | ||
|
||
def run(self, line_data: LineData, target: AnalysisTarget) -> bool: | ||
"""Run filter checks on received token which might be structured. | ||
Args: | ||
line_data: credential candidate data | ||
target: multiline target from which line data was obtained | ||
Return: | ||
True, when need to filter candidate and False if left | ||
""" | ||
# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/ | ||
if not line_data.value: | ||
return True | ||
with contextlib.suppress(Exception): | ||
if line_data.value.startswith("gh") and '_' == line_data.value[3]: | ||
token = line_data.value[4:-6] | ||
data = token.encode(ASCII, errors="strict") | ||
crc32sum = binascii.crc32(data) | ||
base62_crc32 = line_data.value[-6:] | ||
sign_b = base62.decodebytes(base62_crc32) | ||
crc32sign = int.from_bytes(sign_b, "big") | ||
if crc32sign == crc32sum: | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.