1616logger = logging .getLogger (__name__ )
1717
1818
19- def produce_linkage_candidates (
19+ def find_linkage_candidates (
2020 container : Container ,
2121) -> dict [NixDerivation , ProvenanceFlags ]:
2222 latest_complete_channels = (
@@ -93,22 +93,20 @@ def produce_linkage_candidates(
9393 return candidates
9494
9595
96- def build_new_links (container : Container ) -> bool :
96+ def create_derivation_proposal (container : Container ) -> bool :
9797 if container .cve .triaged :
9898 logger .info (
99- "Container received for '%s', but already triaged, skipping linkage." ,
100- container .cve ,
99+ f"Container received for { container .cve } , but already triaged, skipping linkage." ,
101100 )
102101 return False
103102
104103 if CVEDerivationClusterProposal .objects .filter (cve = container .cve ).exists ():
105- logger .info ("Suggestion already exists for '%s' , skipping" , container . cve )
104+ logger .info (f "Suggestion already exists for { container . cve } , skipping" )
106105 return False
107106
108107 if container .tags .filter (value = "exclusively-hosted-service" ).exists ():
109108 logger .info (
110- "Container for '%s' is exclusively-hosted-service, rejecting without match." ,
111- container .cve ,
109+ f"Container for { container .cve } is exclusively-hosted-service, rejecting without match." ,
112110 )
113111 CVEDerivationClusterProposal .objects .create (
114112 cve = container .cve ,
@@ -117,16 +115,14 @@ def build_new_links(container: Container) -> bool:
117115 )
118116 return True
119117
120- drvs = produce_linkage_candidates (container )
118+ drvs = find_linkage_candidates (container )
121119 if not drvs :
122- logger .info ("No derivations matching '%s' , ignoring" , container . cve )
120+ logger .info (f "No derivations matching { container . cve } , ignoring" )
123121 return False
124122
125123 if len (drvs ) > settings .MAX_MATCHES :
126124 logger .warning (
127- "More than '%d' derivations matching '%s', ignoring" ,
128- settings .MAX_MATCHES ,
129- container .cve ,
125+ f"More than { settings .MAX_MATCHES } derivations matching { container .cve } , ignoring" ,
130126 )
131127 return False
132128
@@ -144,14 +140,12 @@ def build_new_links(container: Container) -> bool:
144140
145141 if drvs_throughs :
146142 logger .info (
147- "Matching suggestion for '%s': %d derivations found." ,
148- container .cve ,
149- len (drvs_throughs ),
143+ f"Matching suggestion for { container .cve } : { len (drvs_throughs )} derivations found." ,
150144 )
151145
152146 return True
153147
154148
155149@pgpubsub .post_insert_listener (ContainerChannel )
156- def build_new_links_following_new_containers (old : Container , new : Container ) -> None :
157- build_new_links (new )
150+ def match_derivations_on_container_insert (old : Container , new : Container ) -> None :
151+ create_derivation_proposal (new )
0 commit comments