mirror of
https://github.com/BishopFox/GitGot.git
synced 2026-11-07 09:45:58 -10:00
Fix RFC 1918 Regex and add GitHub search splitting
Error in RFC1918 regex was corrected. Added Github search syntax splitting to mimic web search matching.
This commit is contained in:
1 parent
e557085c91
commit
a8df4c5f3f
2 files changed
+14
-4
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
# RFC 1918 Checks (Approximation)
|
||||
(127\.([0-9\.]{1,3}){3}|10\.([0-9\.]{1,3}){3}|172\.[123][0-9]\.([0-9\.]{1,3}){2}|192\.168\.([0-9\.]{1,3}){2})
|
||||
(127\.([0-9]{1,3}\.){2}[0-9]{1,3}|10\.([0-9]{1,3}\.){2}[0-9]{1,3}|172\.[123][0-9]\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3})
|
||||
|
||||
# Keywords
|
||||
(?i)(secret)
|
||||
|
||||
@@ -16,6 +16,9 @@ import urllib.parse
|
||||
|
||||
SIMILARITY_THRESHOLD = 65
|
||||
ACCESS_TOKEN = "<NO-PERMISSION-GITHUB-TOKEN-HERE>"
|
||||
GITHUB_WHITESPACE = "\\.|,|:|;|/|\\\\|`|'|\"|=|\\*|!|\\?" \
|
||||
"|\\#|\\$|\\&|\\+|\\^|\\||\\~|<|>|\\(" \
|
||||
"|\\)|\\{|\\}|\\[|\\]| "
|
||||
|
||||
|
||||
class bcolors:
|
||||
@@ -390,9 +393,16 @@ def regex_validator(args, state):
|
||||
"a capture group for matches:\n\t" + str(e))
|
||||
sys.exit(-1)
|
||||
state.checks.append(line)
|
||||
for part in [state.query] + state.query.split():
|
||||
escaped_query = part.replace("(", "\\(").replace(")", "\\)")
|
||||
state.checks.append("(?i)(" + escaped_query + ")")
|
||||
|
||||
split = []
|
||||
if not (state.query[0] == "\"" and state.query[-1] == "\""):
|
||||
split = re.split(GITHUB_WHITESPACE, state.query)
|
||||
|
||||
for part in [state.query] + split:
|
||||
if part:
|
||||
escaped_query = re.escape(part) if split else \
|
||||
part.replace("\"", "")
|
||||
state.checks.append("(?i)(" + escaped_query + ")")
|
||||
return state
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user