1010import json
1111from pathlib import Path
1212
13- import dateparser
1413from aboutcode .pipeline import LoopProgress
1514from fetchcode .vcs import fetch_via_vcs
1615
1716from vulnerabilities .models import AdvisoryAlias
18- from vulnerabilities .models import AdvisoryExploit
17+ from vulnerabilities .models import AdvisoryPOC
1918from vulnerabilities .pipelines import VulnerableCodePipeline
2019
2120
2221class GithubPocsImproverPipeline (VulnerableCodePipeline ):
22+ """
23+ Pipeline to Collect an exploit-PoCs repository, parse exploit JSON files,
24+ match them to advisories via aliases, and update/create POC records.
25+ """
26+
2327 pipeline_id = "enhance_with_github_poc"
24- repo_url = "https://github.com/nomi-sec/PoC-in-GitHub"
28+ repo_url = "git+ https://github.com/nomi-sec/PoC-in-GitHub"
2529
2630 @classmethod
2731 def steps (cls ):
@@ -55,8 +59,8 @@ def collect_and_store_exploits(self):
5559 continue
5660
5761 filename = file_path .stem .strip ()
58- advisories = set ()
5962
63+ advisories = set ()
6064 try :
6165 if alias := AdvisoryAlias .objects .get (alias = filename ):
6266 for adv in alias .advisories .all ():
@@ -71,19 +75,16 @@ def collect_and_store_exploits(self):
7175 if not exploit_repo_url :
7276 continue
7377
74- AdvisoryExploit .objects .update_or_create (
78+ AdvisoryPOC .objects .update_or_create (
7579 advisory = advisory ,
76- data_source = "GitHub-PoC" ,
77- source_url = exploit_repo_url ,
80+ url = exploit_repo_url ,
7881 defaults = {
79- "description" : exploit_data .get ("description" ),
80- "source_date_published" : dateparser .parse (
81- exploit_data .get ("created_at" )
82- ),
82+ "created_at" : exploit_data .get ("created_at" ),
83+ "updated_at" : exploit_data .get ("updated_at" ),
8384 },
8485 )
8586
86- self .log (f"Successfully added { exploits_count :,d} exploit advisory" )
87+ self .log (f"Successfully added { exploits_count :,d} poc exploit advisory" )
8788
8889 def clean_downloads (self ):
8990 if self .vcs_response :
0 commit comments