-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from krystianbajno/feature/github-poc
Added Proof of Concept exploits from GitHub
- Loading branch information
Showing
10 changed files
with
101 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ enrichment: | |
sources: | ||
vulners: true | ||
github: true | ||
cisa_kev: true | ||
cisa_kev: true | ||
github_poc: 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
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,10 @@ | ||
from typing import List | ||
from models.vulnerability_intelligence import VulnerabilityIntelligence | ||
from services.vulnerability_intelligence.enrichment.vulnerability_intelligence_enrichment_manager import VulnerabilityIntelligenceEnrichmentManager | ||
|
||
def is_enrichment_enabled(config: dict) -> bool: | ||
return any(config.get('sources', {}).values()) | ||
|
||
def perform_enrichment(vulnerabilities: List[VulnerabilityIntelligence], config: dict) -> List[VulnerabilityIntelligence]: | ||
enrichment_manager = VulnerabilityIntelligenceEnrichmentManager(vulnerabilities, config) | ||
return enrichment_manager.enrich() |
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,6 @@ | ||
from typing import List | ||
from models.vulnerability import Vulnerability | ||
from services.vulnerability_intelligence.processors.vulnerability_intelligence_processor import VulnerabilityIntelligenceProcessor | ||
|
||
def prepare_intelligence_from_vulnerabilities(vulnerabilities: List[Vulnerability], keywords): | ||
return VulnerabilityIntelligenceProcessor.process(vulnerabilities, keywords) |
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
38 changes: 38 additions & 0 deletions
38
services/vulnerability_intelligence/enrichment/enrichment/github_poc.py
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,38 @@ | ||
import httpx | ||
import logging | ||
from typing import Dict | ||
|
||
def fetch_github_poc_data(cve: str) -> Dict: | ||
year = cve.split('-')[1] | ||
url = f"https://raw.githubusercontent.com/nomi-sec/PoC-in-GitHub/refs/heads/master/{year}/{cve}.json" | ||
|
||
pocs = [] | ||
|
||
try: | ||
response = httpx.get(url, timeout=15) | ||
|
||
if response.status_code == 200: | ||
json_data = response.json() | ||
|
||
|
||
for entry in json_data: | ||
data = { | ||
'github_url': 'N/A', | ||
'github_description': None, | ||
'github_date': 'N/A', | ||
'github_tags': [], | ||
'github_stars': 0 | ||
} | ||
|
||
data['github_url'] = entry["html_url"] | ||
data['github_description'] = entry["description"] | ||
data['github_date'] = entry["updated_at"] | ||
data['github_tags'].extend(entry["topics"]) | ||
data['github_stars'] = entry["stargazers_count"] | ||
|
||
pocs.append(data) | ||
|
||
except Exception as e: | ||
logging.error(f"Error fetching JSON PoC data for CVE {cve}: {e}") | ||
|
||
return pocs |
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
34 changes: 34 additions & 0 deletions
34
services/vulnerability_intelligence/handlers/github_poc_handler.py
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,34 @@ | ||
from services.vulnerability_intelligence.handlers.base_handler import BaseHandler | ||
from models.vulnerability_intelligence import VulnerabilityIntelligence | ||
import logging | ||
|
||
class GitHubPoCHandler(BaseHandler): | ||
def apply(self, vuln_intelligence: VulnerabilityIntelligence): | ||
try: | ||
sorted_data = sorted(self.data, key=lambda entry: entry.get('github_stars', 0), reverse=True) | ||
|
||
for entry in sorted_data: | ||
github_url = entry.get('github_url', "N/A") | ||
github_date = entry.get('github_date', "N/A") | ||
github_description = entry.get('github_description') | ||
github_tags = entry.get('github_tags', []) | ||
github_stars = entry.get('github_stars') | ||
|
||
if github_description: | ||
vuln_intelligence.descriptions.append({ | ||
"source": self.enrich_source_name("GitHub PoC"), | ||
"text": github_description, | ||
"date": github_date | ||
}) | ||
|
||
vuln_intelligence.urls.append({ | ||
"source": self.enrich_source_name(f"GitHub - PoC Exploit [{github_stars} ⭐]"), | ||
"url": github_url, | ||
"date": github_date | ||
}) | ||
|
||
vuln_intelligence.reference_urls.update([github_url]) | ||
vuln_intelligence.tags.update(github_tags) | ||
|
||
except Exception as e: | ||
logging.error(f"Error applying GitHub JSON PoC enrichment: {e}") |