grr/server/grr_response_server/gui/selenium_tests/hunt_copy_test.py
def testCopyHuntHandlesLiteralExpressionCorrectly(self):
    """Literals are raw bytes. Testing that raw bytes are processed right."""
    literal_match = rdf_file_finder.FileFinderContentsLiteralMatchCondition(
        literal=b"foo\x0d\xc8bar")

    self.StartHunt(
        description="model hunt",
        flow_runner_args=rdf_flow_runner.FlowRunnerArgs(
            flow_name=file_finder.FileFinder.__name__),
        flow_args=rdf_file_finder.FileFinderArgs(
            conditions=[
                rdf_file_finder.FileFinderCondition(
                    condition_type="CONTENTS_LITERAL_MATCH",
                    contents_literal_match=literal_match)
            ],
            paths=["/tmp/evil.txt"]),
        token=self.token)

    self.Open("/#main=ManageHunts")
    self.Click("css=tr:contains('model hunt')")
    self.Click("css=button[name=CopyHunt]:not([disabled])")

    # Wait until dialog appears.
    self.WaitUntil(self.IsTextPresent, "What to run?")

    # Check that non-default values of sample hunt are prefilled.
    self.WaitUntilEqual(
        "foo\\x0d\\xc8bar", self.GetValue, "css=grr-new-hunt-wizard-form "
        "label:contains('Literal') ~ * input:text")

    # Click on "Next" button
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsElementPresent,
                   "css=grr-wizard-form:contains('Hunt parameters')")
    # Click on "Next" button.
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "How to process results")
    # Click on "Next" button
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Where to run?")
    # Click on "Next" button
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Review")

    # Check that the arguments summary is present.
    self.WaitUntil(self.IsTextPresent, file_finder.FileFinder.__name__)
    self.WaitUntil(self.IsTextPresent, "foo\\x0d\\xc8bar")

    # Click on "Run" button
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Created Hunt")
    # Close the window and check that the hunt was created.
    self.Click("css=button.Next")

    if data_store.RelationalDBReadEnabled("hunts"):
      hunts_list = sorted(
          data_store.REL_DB.ReadAllHuntObjects(), key=lambda x: x.create_time)

      self.assertLen(hunts_list, 2)

      last_hunt = hunts_list[-1]

      # Check that the hunt was created with a correct literal value.
      self.assertEqual(last_hunt.args.standard.flow_name,
                       file_finder.FileFinder.__name__)
      self.assertEqual(
          last_hunt.args.standard.flow_args.conditions[0].contents_literal_match
          .literal, b"foo\x0d\xc8bar")
    else:
      hunts_root = aff4.FACTORY.Open("aff4:/hunts", token=self.token)
      hunts_list = sorted(list(hunts_root.ListChildren()), key=lambda x: x.age)

      self.assertLen(hunts_list, 2)
      last_hunt = aff4.FACTORY.Open(hunts_list[-1], token=self.token)

      # Check that the hunt was created with a correct literal value.
      self.assertEqual(last_hunt.args.flow_runner_args.flow_name,
                       file_finder.FileFinder.__name__)
      self.assertEqual(
          last_hunt.args.flow_args.conditions[0].contents_literal_match.literal,
          b"foo\x0d\xc8bar")
Literals are raw bytes. Testing that raw bytes are processed right.
Literals are raw bytes. Testing that raw bytes are processed right.
Literals are raw bytes . Testing that raw bytes are processed right .
def testCopyHuntHandlesLiteralExpressionCorrectly(self):
    literal_match = rdf_file_finder.FileFinderContentsLiteralMatchCondition(
        literal=b"foo\x0d\xc8bar")
    self.StartHunt(
        description="model hunt",
        flow_runner_args=rdf_flow_runner.FlowRunnerArgs(
            flow_name=file_finder.FileFinder.__name__),
        flow_args=rdf_file_finder.FileFinderArgs(
            conditions=[
                rdf_file_finder.FileFinderCondition(
                    condition_type="CONTENTS_LITERAL_MATCH",
                    contents_literal_match=literal_match)
            ],
            paths=["/tmp/evil.txt"]),
        token=self.token)
    self.Open("/#main=ManageHunts")
    self.Click("css=tr:contains('model hunt')")
    self.Click("css=button[name=CopyHunt]:not([disabled])")
    self.WaitUntil(self.IsTextPresent, "What to run?")
    self.WaitUntilEqual(
        "foo\\x0d\\xc8bar", self.GetValue, "css=grr-new-hunt-wizard-form "
        "label:contains('Literal') ~ * input:text")
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsElementPresent,
                   "css=grr-wizard-form:contains('Hunt parameters')")
    .
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "How to process results")
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Where to run?")
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Review")
    self.WaitUntil(self.IsTextPresent, file_finder.FileFinder.__name__)
    self.WaitUntil(self.IsTextPresent, "foo\\x0d\\xc8bar")
    self.Click("css=grr-new-hunt-wizard-form button.Next")
    self.WaitUntil(self.IsTextPresent, "Created Hunt")
    self.Click("css=button.Next")
    if data_store.RelationalDBReadEnabled("hunts"):
      hunts_list = sorted(
          data_store.REL_DB.ReadAllHuntObjects(), key=lambda x: x.create_time)
      self.assertLen(hunts_list, 2)
      last_hunt = hunts_list[-1]
      self.assertEqual(last_hunt.args.standard.flow_name,
                       file_finder.FileFinder.__name__)
      self.assertEqual(
          last_hunt.args.standard.flow_args.conditions[0].contents_literal_match
          .literal, b"foo\x0d\xc8bar")
    else:
      hunts_root = aff4.FACTORY.Open("aff4:/hunts", token=self.token)
      hunts_list = sorted(list(hunts_root.ListChildren()), key=lambda x: x.age)
      self.assertLen(hunts_list, 2)
      last_hunt = aff4.FACTORY.Open(hunts_list[-1], token=self.token)
      self.assertEqual(last_hunt.args.flow_runner_args.flow_name,
                       file_finder.FileFinder.__name__)
      self.assertEqual(
          last_hunt.args.flow_args.conditions[0].contents_literal_match.literal,
          b"foo\x0d\xc8bar")
def testCopyHuntHandlesLiteralExpressionCorrectly ( self ) : literal_match = rdf_file_finder . FileFinderContentsLiteralMatchCondition ( literal = b"foo\x0d\xc8bar" ) self . StartHunt ( description = "model hunt" , flow_runner_args = rdf_flow_runner . FlowRunnerArgs ( flow_name = file_finder . FileFinder . __name__ ) , flow_args = rdf_file_finder . FileFinderArgs ( conditions = [ rdf_file_finder . FileFinderCondition ( condition_type = "CONTENTS_LITERAL_MATCH" , contents_literal_match = literal_match ) ] , paths = [ "/tmp/evil.txt" ] ) , token = self . token ) self . Open ( "/#main=ManageHunts" ) self . Click ( "css=tr:contains('model hunt')" ) self . Click ( "css=button[name=CopyHunt]:not([disabled])" ) self . WaitUntil ( self . IsTextPresent , "What to run?" ) self . WaitUntilEqual ( "foo\\x0d\\xc8bar" , self . GetValue , "css=grr-new-hunt-wizard-form " "label:contains('Literal') ~ * input:text" ) self . Click ( "css=grr-new-hunt-wizard-form button.Next" ) self . WaitUntil ( self . IsElementPresent , "css=grr-wizard-form:contains('Hunt parameters')" ) self . Click ( "css=grr-new-hunt-wizard-form button.Next" ) self . WaitUntil ( self . IsTextPresent , "How to process results" ) self . Click ( "css=grr-new-hunt-wizard-form button.Next" ) self . WaitUntil ( self . IsTextPresent , "Where to run?" ) self . Click ( "css=grr-new-hunt-wizard-form button.Next" ) self . WaitUntil ( self . IsTextPresent , "Review" ) self . WaitUntil ( self . IsTextPresent , file_finder . FileFinder . __name__ ) self . WaitUntil ( self . IsTextPresent , "foo\\x0d\\xc8bar" ) self . Click ( "css=grr-new-hunt-wizard-form button.Next" ) self . WaitUntil ( self . IsTextPresent , "Created Hunt" ) self . Click ( "css=button.Next" ) if data_store . RelationalDBReadEnabled ( "hunts" ) : hunts_list = sorted ( data_store . REL_DB . ReadAllHuntObjects ( ) , key = lambda x : x . create_time ) self . assertLen ( hunts_list , 2 ) last_hunt = hunts_list [ - 1 ] self . assertEqual ( last_hunt . args . standard . flow_name , file_finder . FileFinder . __name__ ) self . assertEqual ( last_hunt . args . standard . flow_args . conditions [ 0 ] . contents_literal_match . literal , b"foo\x0d\xc8bar" ) else : hunts_root = aff4 . FACTORY . Open ( "aff4:/hunts" , token = self . token ) hunts_list = sorted ( list ( hunts_root . ListChildren ( ) ) , key = lambda x : x . age ) self . assertLen ( hunts_list , 2 ) last_hunt = aff4 . FACTORY . Open ( hunts_list [ - 1 ] , token = self . token ) self . assertEqual ( last_hunt . args . flow_runner_args . flow_name , file_finder . FileFinder . __name__ ) self . assertEqual ( last_hunt . args . flow_args . conditions [ 0 ] . contents_literal_match . literal , b"foo\x0d\xc8bar" )
Literals are raw bytes.
Literals are raw bytes .
"""Literals are raw bytes. Testing that raw bytes are processed right.""" # Wait until dialog appears. # Check that non-default values of sample hunt are prefilled. # Click on "Next" button # Click on "Next" button. # Click on "Next" button # Click on "Next" button # Check that the arguments summary is present. # Click on "Run" button # Close the window and check that the hunt was created. # Check that the hunt was created with a correct literal value. # Check that the hunt was created with a correct literal value.
self