-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOAR-17247-Better error handling and general improvemtns (#2722)
- Loading branch information
1 parent
9d8b4c8
commit 85328e2
Showing
20 changed files
with
404 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nd_misp/actions/add_sightings/__init__.py → ...and_misp/actions/add_sighting/__init__.py
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT | ||
from .action import AddSightings | ||
from .action import AddSighting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import insightconnect_plugin_runtime | ||
from insightconnect_plugin_runtime.exceptions import PluginException | ||
|
||
from .schema import AddSightingInput, AddSightingOutput, Input, Output, Component | ||
|
||
# Custom imports below | ||
|
||
|
||
class AddSighting(insightconnect_plugin_runtime.Action): | ||
def __init__(self): | ||
super(self.__class__, self).__init__( | ||
name="add_sighting", | ||
description=Component.DESCRIPTION, | ||
input=AddSightingInput(), | ||
output=AddSightingOutput(), | ||
) | ||
|
||
def run(self, params={}): | ||
|
||
mappings = {"Sighting": 0, "False-positive": 1, "Expiration": 2} | ||
|
||
sighting = { | ||
"source": params.get(Input.SOURCE, ""), | ||
"type": mappings.get(params.get(Input.TYPE)), | ||
"date": params.get(Input.DATE, ""), | ||
"time": params.get(Input.TIME, ""), | ||
} | ||
|
||
client = self.connection.client | ||
try: | ||
item = client.add_sighting(sighting=sighting, attribute=int(params.get(Input.ATTRIBUTE))) | ||
if item.get("Sighting"): | ||
return {Output.SIGHTING: item.get("Sighting")} | ||
else: | ||
self.logger.error(item) | ||
raise PluginException(preset=PluginException.Preset.UNKNOWN) | ||
except Exception as error: | ||
self.logger.error(error) | ||
raise PluginException(preset=PluginException.Preset.UNKNOWN, data=error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT | ||
import insightconnect_plugin_runtime | ||
import json | ||
|
||
|
||
class Component: | ||
DESCRIPTION = "Add a sighting to attribute" | ||
|
||
|
||
class Input: | ||
ATTRIBUTE = "attribute" | ||
DATE = "date" | ||
SOURCE = "source" | ||
TIME = "Time" | ||
TYPE = "type" | ||
|
||
|
||
class Output: | ||
SIGHTING = "sighting" | ||
|
||
|
||
class AddSightingInput(insightconnect_plugin_runtime.Input): | ||
schema = json.loads(r""" | ||
{ | ||
"type": "object", | ||
"title": "Variables", | ||
"properties": { | ||
"Time": { | ||
"type": "string", | ||
"title": "Time", | ||
"description": "The time of the sighting to be added to the attribute (if none is provided it will default to now)", | ||
"order": 5 | ||
}, | ||
"attribute": { | ||
"type": "integer", | ||
"title": "Attribute", | ||
"description": "The ID of the attribute to add the sighting to", | ||
"order": 1 | ||
}, | ||
"date": { | ||
"type": "string", | ||
"title": "Date", | ||
"description": "The date of the sighting to be added to the attribute (if none is provided it will default to now)", | ||
"order": 4 | ||
}, | ||
"source": { | ||
"type": "string", | ||
"title": "Source", | ||
"description": "The source of the sighting to be added to the attribute", | ||
"order": 3 | ||
}, | ||
"type": { | ||
"type": "string", | ||
"title": "Type", | ||
"description": "The type of sighting to be added to the attribute", | ||
"enum": [ | ||
"Sighting", | ||
"False-positive", | ||
"Expiration" | ||
], | ||
"order": 2 | ||
} | ||
}, | ||
"required": [ | ||
"attribute", | ||
"type" | ||
], | ||
"definitions": {} | ||
} | ||
""") | ||
|
||
def __init__(self): | ||
super(self.__class__, self).__init__(self.schema) | ||
|
||
|
||
class AddSightingOutput(insightconnect_plugin_runtime.Output): | ||
schema = json.loads(r""" | ||
{ | ||
"type": "object", | ||
"title": "Variables", | ||
"properties": { | ||
"sighting": { | ||
"type": "object", | ||
"title": "Sighting", | ||
"description": "Whether any of the sightings provided were added", | ||
"order": 1 | ||
} | ||
}, | ||
"definitions": {} | ||
} | ||
""") | ||
|
||
def __init__(self): | ||
super(self.__class__, self).__init__(self.schema) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.