Example #1
0
def baseline_command(
    target_key,
    target_plugin,
    inventory_plugin,
    persistence_plugin,
    payload_plugin,
    collection_plugin,
    incident_id,
    **kwargs,
):
    """Creates a new baseline based on the given ASG."""
    if inventory_plugin:
        for item in inventory_plugin['plugin'].get():
            target_plugin['options'] = item['options']
            baseline(
                item['target'],
                item['target_plugin'],
                payload_plugin,
                collection_plugin,
                persistence_plugin,
                incident_id=incident_id,
                **kwargs,
            )

    baselines = baseline(
        target_key,
        target_plugin,
        payload_plugin,
        collection_plugin,
        persistence_plugin,
        incident_id=incident_id,
        **kwargs,
    )
    click.secho(json.dumps(baselines), fg="green")
Example #2
0
    def post(self, data=None):
        """
        .. http:post:: /baselines
          The current list of baselines

          **Example request**:
          .. sourcecode:: http
             GET /baselines HTTP/1.1
             Host: example.com
             Accept: application/json, text/javascript

          **Example response**:
          .. sourcecode:: http
             HTTP/1.1 200 OK
             Vary: Accept
             Content-Type: text/javascript

             # TODO

          :statuscode 200: no error
          :statuscode 403: unauthenticated
        """
        try:
            return baseline(**data)
        except TargetNotFound as ex:
            return {'message': ex.message}, 404
Example #3
0
def baseline_command(target_key, incident_id, target_plugin,
                     persistence_plugin, collection_plugin, payload_plugin,
                     **kwargs):
    """Creates a new baseline based on the given ASG."""
    baselines = baseline(target_key,
                         target_plugin,
                         payload_plugin,
                         collection_plugin,
                         persistence_plugin,
                         incident_id=incident_id,
                         **kwargs)
    click.secho(json.dumps(baselines), fg='green')
Example #4
0
def baseline_command(target_key, incident_id, target_plugin, persistence_plugin, collection_plugin, payload_plugin,
                     **kwargs):
    """Creates a new baseline based on the given ASG."""
    baselines = baseline(
        target_key,
        target_plugin,
        payload_plugin,
        collection_plugin,
        persistence_plugin,
        incident_id=incident_id,
        **kwargs
    )
    click.secho(json.dumps(baselines), fg='green')
Example #5
0
def async_baseline(kwargs):
    """Wrapper job around our standard baseline task."""
    # we can't pickle our objects for remote works so we pickle the raw request and then load it here.
    data = baseline_input_schema.load(kwargs).data
    return baseline(**data)