@@ -207,17 +207,19 @@ def verify_policy(verify_policy_args: argparse.Namespace) -> int:
207207 policy_content = file .read ()
208208 elif verify_policy_args .policy :
209209 policy_dir = os .path .join (macaron .MACARON_PATH , "resources/policies/datalog" )
210- available_policies = [policy [:- 3 ] for policy in os .listdir (policy_dir ) if policy .endswith (".dl" )]
210+ available_policies = [policy [:- 12 ] for policy in os .listdir (policy_dir ) if policy .endswith (".dl.template " )]
211211 if verify_policy_args .policy not in available_policies :
212212 logger .error (
213213 "The policy %s is not available. Available policies are: %s" ,
214214 verify_policy_args .policy ,
215215 available_policies ,
216216 )
217217 return os .EX_USAGE
218- policy_path = os .path .join (policy_dir , f"{ verify_policy_args .policy } .dl" )
218+ policy_path = os .path .join (policy_dir , f"{ verify_policy_args .policy } .dl.template " )
219219 with open (policy_path , encoding = "utf-8" ) as file :
220220 policy_content = file .read ()
221+ if verify_policy_args .package_url :
222+ policy_content = policy_content .replace ("<PACKAGE_PURL>" , verify_policy_args .package_url )
221223
222224 if policy_content :
223225 result = run_policy_engine (verify_policy_args .database , policy_content )
@@ -553,6 +555,7 @@ def main(argv: list[str] | None = None) -> None:
553555 vp_group = vp_parser .add_mutually_exclusive_group (required = True )
554556
555557 vp_parser .add_argument ("-d" , "--database" , required = True , type = str , help = "Path to the database." )
558+ vp_parser .add_argument ("-purl" , "--package-url" , help = "PackageURL for policy template." )
556559 vp_group .add_argument ("-f" , "--file" , type = str , help = "Path to the Datalog policy." )
557560 vp_group .add_argument ("-p" , "--policy" , help = "Example policy to run." )
558561 vp_group .add_argument ("-s" , "--show-prelude" , action = "store_true" , help = "Show policy prelude." )
0 commit comments