-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added text module to connect with other programms, so that they can i…
…mport it
- Loading branch information
1 parent
09875b1
commit 5c1d8d9
Showing
3 changed files
with
82 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from hawk_scanner.internals import system | ||
from rich.console import Console | ||
|
||
console = Console() | ||
|
||
def check_data_patterns(value, patterns, profile_name): | ||
value_str = str(value) | ||
matches = system.match_strings(value_str) | ||
results = [] | ||
if matches: | ||
for match in matches: | ||
results.append({ | ||
'pattern_name': match['pattern_name'], | ||
'matches': match['matches'], | ||
'sample_text': match['sample_text'], | ||
'profile': profile_name, | ||
'data_source': 'text' | ||
}) | ||
return results | ||
|
||
def execute(args, programmatic=False): | ||
results = [] | ||
system.print_info(f"Running Checks for Simple text") | ||
connections = system.get_connection() | ||
patterns = system.get_fingerprint_file() | ||
|
||
if not programmatic: | ||
if 'sources' in connections: | ||
sources_config = connections['sources'] | ||
text_config = sources_config.get('text') | ||
|
||
if text_config: | ||
for key, config in text_config.items(): | ||
text = config.get('text', None) | ||
results += check_data_patterns(text, patterns, key) | ||
else: | ||
system.print_error("No text connection details found in connection.yml") | ||
else: | ||
system.print_error("No 'sources' section found in connection.yml") | ||
else: | ||
text = args.get('text', None) | ||
results += check_data_patterns(text, patterns, 'text') | ||
return results | ||
|
||
# Example usage | ||
if __name__ == "__main__": | ||
execute(None) |
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,4 +1,4 @@ | ||
VERSION = "0.3.7" | ||
VERSION = "0.3.8" | ||
|
||
from setuptools import setup, find_packages | ||
|
||
|