@@ -214,17 +214,19 @@ def verify_policy(verify_policy_args: argparse.Namespace) -> int:
214214 policy_content = file .read ()
215215 elif verify_policy_args .policy :
216216 policy_dir = os .path .join (macaron .MACARON_PATH , "resources/policies/datalog" )
217- available_policies = [policy [:- 3 ] for policy in os .listdir (policy_dir ) if policy .endswith (".dl" )]
217+ available_policies = [policy [:- 12 ] for policy in os .listdir (policy_dir ) if policy .endswith (".dl.template " )]
218218 if verify_policy_args .policy not in available_policies :
219219 logger .error (
220220 "The policy %s is not available. Available policies are: %s" ,
221221 verify_policy_args .policy ,
222222 available_policies ,
223223 )
224224 return os .EX_USAGE
225- policy_path = os .path .join (policy_dir , f"{ verify_policy_args .policy } .dl" )
225+ policy_path = os .path .join (policy_dir , f"{ verify_policy_args .policy } .dl.template " )
226226 with open (policy_path , encoding = "utf-8" ) as file :
227227 policy_content = file .read ()
228+ if verify_policy_args .package_url :
229+ policy_content = policy_content .replace ("<PACKAGE_PURL>" , verify_policy_args .package_url )
228230
229231 if policy_content :
230232 result = run_policy_engine (verify_policy_args .database , policy_content )
@@ -588,6 +590,7 @@ def main(argv: list[str] | None = None) -> None:
588590 vp_group = vp_parser .add_mutually_exclusive_group (required = True )
589591
590592 vp_parser .add_argument ("-d" , "--database" , required = True , type = str , help = "Path to the database." )
593+ vp_parser .add_argument ("-purl" , "--package-url" , help = "PackageURL for policy template." )
591594 vp_group .add_argument ("-f" , "--file" , type = str , help = "Path to the Datalog policy." )
592595 vp_group .add_argument ("-p" , "--policy" , help = "Example policy to run." )
593596 vp_group .add_argument ("-s" , "--show-prelude" , action = "store_true" , help = "Show policy prelude." )
0 commit comments