|
| 1 | +import jmespath |
1 | 2 | from rich.console import Console |
2 | 3 | from rich.table import Table |
3 | 4 | import json, requests, argparse, yaml, re, datetime, os, subprocess, platform, hashlib |
@@ -541,6 +542,40 @@ def SlackNotify(msg, args): |
541 | 542 | except Exception as e: |
542 | 543 | print_error(args, f"An error occurred: {str(e)}") |
543 | 544 |
|
| 545 | +def evaluate_severity(json_data, rules): |
| 546 | + if 'severity_rules' not in rules: |
| 547 | + rules = { |
| 548 | + 'severity_rules': { |
| 549 | + 'critical': [ |
| 550 | + {'query': "length(matches) > `20`", 'description': "Detected more than 20 PII or Secrets"}, |
| 551 | + ], |
| 552 | + 'high': [ |
| 553 | + {'query': "length(matches) > `10` && length(matches) <= `20`", 'description': "Detected more than 10 PII or Secrets"}, |
| 554 | + ], |
| 555 | + 'medium': [ |
| 556 | + {'query': "length(matches) > `5` && length(matches) <= `10`", 'description': "Detected more than 5 PII or Secrets"}, |
| 557 | + ], |
| 558 | + 'low': [ |
| 559 | + {'query': "length(matches) <= `5`", 'description': "Detected less than 5 PII or Secrets"}, |
| 560 | + ], |
| 561 | + } |
| 562 | + } |
| 563 | + |
| 564 | + for severity, conditions in rules['severity_rules'].items(): |
| 565 | + for condition in conditions: |
| 566 | + query = condition['query'] |
| 567 | + description = condition['description'] |
| 568 | + if jmespath.search(query, json_data): |
| 569 | + # Add severity details to the JSON data |
| 570 | + json_data['severity'] = severity |
| 571 | + json_data['severity_description'] = description |
| 572 | + return json_data |
| 573 | + |
| 574 | + # If no match, add default severity |
| 575 | + json_data['severity'] = "unknown" |
| 576 | + json_data['severity_description'] = "No matching rule found." |
| 577 | + return json_data |
| 578 | + |
544 | 579 | def enhance_and_ocr(image_path): |
545 | 580 | # Load the image |
546 | 581 | original_image = Image.open(image_path) |
|
0 commit comments