grr/server/grr_response_server/artifact_test.py
def testCmdArtifact(self):
    """Check we can run command based artifacts and get anomalies."""
    client_id = test_lib.TEST_CLIENT_ID
    client_mock = self.MockClient(standard.ExecuteCommand, client_id=client_id)
    with utils.Stubber(subprocess, "Popen", client_test_lib.Popen):
      session_id = flow_test_lib.TestFlowHelper(
          collectors.ArtifactCollectorFlow.__name__,
          client_mock,
          client_id=client_id,
          use_tsk=False,
          artifact_list=["TestCmdArtifact"],
          token=self.token)

    results = flow_test_lib.GetFlowResults(client_id, session_id)
    self.assertLen(results, 3)
    packages = [p for p in results if isinstance(p, rdf_client.SoftwarePackage)]
    self.assertLen(packages, 2)

    anomalies = [a for a in results if isinstance(a, rdf_anomaly.Anomaly)]
    self.assertLen(anomalies, 1)
    self.assertIn("gremlin", anomalies[0].symptom)
Check we can run command based artifacts and get anomalies.
Check we can run command based artifacts and get anomalies.
Check we can run command based artifacts and get anomalies .
def testCmdArtifact(self):
    client_id = test_lib.TEST_CLIENT_ID
    client_mock = self.MockClient(standard.ExecuteCommand, client_id=client_id)
    with utils.Stubber(subprocess, "Popen", client_test_lib.Popen):
      session_id = flow_test_lib.TestFlowHelper(
          collectors.ArtifactCollectorFlow.__name__,
          client_mock,
          client_id=client_id,
          use_tsk=False,
          artifact_list=["TestCmdArtifact"],
          token=self.token)
    results = flow_test_lib.GetFlowResults(client_id, session_id)
    self.assertLen(results, 3)
    packages = [p for p in results if isinstance(p, rdf_client.SoftwarePackage)]
    self.assertLen(packages, 2)
    anomalies = [a for a in results if isinstance(a, rdf_anomaly.Anomaly)]
    self.assertLen(anomalies, 1)
    self.assertIn("gremlin", anomalies[0].symptom)
def testCmdArtifact ( self ) : client_id = test_lib . TEST_CLIENT_ID client_mock = self . MockClient ( standard . ExecuteCommand , client_id = client_id ) with utils . Stubber ( subprocess , "Popen" , client_test_lib . Popen ) : session_id = flow_test_lib . TestFlowHelper ( collectors . ArtifactCollectorFlow . __name__ , client_mock , client_id = client_id , use_tsk = False , artifact_list = [ "TestCmdArtifact" ] , token = self . token ) results = flow_test_lib . GetFlowResults ( client_id , session_id ) self . assertLen ( results , 3 ) packages = [ p for p in results if isinstance ( p , rdf_client . SoftwarePackage ) ] self . assertLen ( packages , 2 ) anomalies = [ a for a in results if isinstance ( a , rdf_anomaly . Anomaly ) ] self . assertLen ( anomalies , 1 ) self . assertIn ( "gremlin" , anomalies [ 0 ] . symptom )
Check we can run command based artifacts and get anomalies.
Check we can run command based artifacts and get anomalies .
"""Check we can run command based artifacts and get anomalies."""
self