Exemple #1
0
  def Run(self):

    def ReplaceCronJobUrn():
      jobs = list(aff4_cronjobs.GetCronManager().ListJobs(token=self.token))
      return {jobs[0]: "CreateAndRunGenericHuntFlow_1234"}

    flow_name = file_finder.FileFinder.__name__
    flow_args = rdf_file_finder.FileFinderArgs(
        paths=["c:\\windows\\system32\\notepad.*"])

    hunt_runner_args = rdf_hunts.HuntRunnerArgs()
    hunt_runner_args.client_rule_set.rules = [
        foreman_rules.ForemanClientRule(
            os=foreman_rules.ForemanOsClientRule(os_windows=True))
    ]
    hunt_runner_args.description = "Foobar! (cron)"

    self.Check(
        "CreateCronJob",
        args=cron_plugin.ApiCreateCronJobArgs(
            description="Foobar!",
            flow_name=flow_name,
            flow_args=flow_args,
            hunt_runner_args=hunt_runner_args,
            periodicity=604800,
            lifetime=3600),
        replace=ReplaceCronJobUrn)
Exemple #2
0
 def testAddForemanRulesHuntRunnerArgumentIsNotRespected(self):
     args = cron_plugin.ApiCreateCronJobArgs(
         flow_name=flow_test_lib.FlowWithOneNestedFlow.__name__,
         hunt_runner_args=rdf_hunts.HuntRunnerArgs(
             # Default is True.
             add_foreman_rules=False))
     result = self.handler.Handle(args, context=self.context)
     self.assertTrue(
         result.args.hunt_cron_action.hunt_runner_args.add_foreman_rules)