-
Notifications
You must be signed in to change notification settings - Fork 48
Basic & bearer authorization patterns #733
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f9c56df
basic&bearer authorization rules
babenek b88c9e0
[skip actions] [basic] 2025-06-27T00:08:12+03:00
babenek 6ad2149
custom BM ref
babenek add485a
test samples and scores
babenek 61e4d72
space as separator
babenek b906891
space as separator, style
babenek ba5a7f9
style
babenek c5b657d
Merge branch 'main' into basic
babenek 85fb7c6
BM fix
babenek 722818e
confidence: moderate
babenek 83c5ead
Docs update
babenek 35bf6cc
Merge branch 'main' into basic
babenek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| import contextlib | ||
| import logging | ||
|
|
||
| from credsweeper.common.constants import DEFAULT_PATTERN_LEN, UTF_8 | ||
| from credsweeper.config.config import Config | ||
| from credsweeper.credentials.line_data import LineData | ||
| from credsweeper.file_handler.analysis_target import AnalysisTarget | ||
| from credsweeper.filters.filter import Filter | ||
| from credsweeper.utils.util import Util | ||
|
|
||
|
|
||
| class ValueBasicAuthCheck(Filter): | ||
| """Check that candidate have a known structure""" | ||
|
|
||
| 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, if need to filter candidate and False if left | ||
|
|
||
| """ | ||
| value = line_data.value | ||
| with contextlib.suppress(Exception): | ||
| # Basic encoding -> login:password | ||
| decoded = Util.decode_base64(value, padding_safe=True, urlsafe_detect=True) | ||
| delimiter_pos = decoded.find(b':') | ||
| # check whether the delimiter exists and all chars are decoded | ||
| if 0 < delimiter_pos < len(decoded) - DEFAULT_PATTERN_LEN and decoded.decode(UTF_8): | ||
| return False | ||
| return True |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.