88from application .database import db
99from application .defs import cre_defs as defs
1010from application .prompt_client import prompt_client
11+ from application .utils import mapping_fixtures
1112from application .utils .external_project_parsers .parsers import owasp_llm_top10_2025
1213
1314
@@ -25,13 +26,17 @@ def setUp(self) -> None:
2526 self .collection = db .Node_collection ()
2627
2728 def test_parse (self ) -> None :
28- for cre_id , name in [
29- ("161-451" , "Output encoding and injection prevention" ),
30- ("064-808" , "Encode output context-specifically" ),
31- ("760-764" , "Injection protection" ),
32- ("623-550" , "Denial Of Service protection" ),
33- ]:
34- self .collection .add_cre (defs .CRE (id = cre_id , name = name , description = "" ))
29+ # Seed the AI-topic hub CREs from the LLM mapping fixture (not classic web CREs).
30+ gold = mapping_fixtures .load_owasp_mapping_fixture ("owasp_llm_top10_2025" )
31+ seeded : set [str ] = set ()
32+ for entry in gold :
33+ for cre_id in entry ["cre_ids" ]:
34+ if cre_id in seeded :
35+ continue
36+ self .collection .add_cre (
37+ defs .CRE (id = cre_id , name = f"CRE { cre_id } " , description = "" )
38+ )
39+ seeded .add (cre_id )
3540
3641 result = owasp_llm_top10_2025 .OwaspLlmTop10_2025 ().parse (
3742 self .collection , prompt_client .PromptHandler (database = self .collection )
@@ -42,8 +47,12 @@ def test_parse(self) -> None:
4247 self .assertEqual ("LLM01" , entries [0 ].sectionID )
4348 self .assertEqual ("Prompt Injection" , entries [0 ].section )
4449 self .assertEqual (
45- ["161-451" , "760-764" ], [link .document .id for link in entries [0 ].links ]
50+ ["012-625" , "686-110" ],
51+ [link .document .id for link in entries [0 ].links ],
52+ )
53+ self .assertEqual (
54+ ["044-202" , "780-757" ],
55+ [link .document .id for link in entries [4 ].links ],
4656 )
47- self .assertEqual (["064-808" ], [link .document .id for link in entries [4 ].links ])
4857 self .assertEqual ("LLM10" , entries [- 1 ].sectionID )
49- self .assertEqual (["623-550 " ], [link .document .id for link in entries [- 1 ].links ])
58+ self .assertEqual (["230-318 " ], [link .document .id for link in entries [- 1 ].links ])
0 commit comments