Skip to content

Commit

Permalink
Merge pull request #1205 from SEKOIA-IO/fix-asset-actions
Browse files Browse the repository at this point in the history
fix create asset url
  • Loading branch information
ysindel authored Dec 16, 2024
2 parents 7c7cc5a + 71c2a55 commit 9e8912f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 37 deletions.
10 changes: 7 additions & 3 deletions Sekoia.io/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
AddsKeyToAsset,
AssociateNewAlertsOnCase,
CreatesNewAsset,
CreatesNewAssetV2,
CreateRule,
DeletesAsset,
DeletesAssetV2,
DeleteRule,
DenyCountermeasure,
DisableRule,
Expand Down Expand Up @@ -64,6 +66,7 @@
module.register(AddsKeyToAsset, "post-assets/{uuid}/keys")
module.register(AssociateNewAlertsOnCase, "patch-cases/{case_uuid}/alerts")
module.register(CreatesNewAsset, "post-assets")
module.register(CreatesNewAssetV2, "post-assets-v2")
module.register(CreateRule, "post-rules")
module.register(DeleteRule, "delete-rules/{uuid}")
module.register(DenyCountermeasure, "patch-alerts/countermeasures/{cm_uuid}/deny")
Expand All @@ -90,9 +93,10 @@
module.register(UpdateAlertStatus, "patch-alerts-v2/{uuid}/workflow")
module.register(PushEventToIntake, "push-events-to-intake")
module.register(ListAssets, "get-assets-v2")
module.register(DeletesAsset, "delete-assets-v2/{uuid}")
module.register(GetAsset, "get-assets/{uuid}")
module.register(ReturnsAsset, "get-assets-v2/{uuid}")
module.register(DeletesAsset, "delete-assets/{uuid}")
module.register(DeletesAssetV2, "delete-assets-v2/{uuid}")
module.register(GetAsset, "get-assets-v2/{uuid}")
module.register(ReturnsAsset, "get-assets/{uuid}")
module.register(UpdateRule, "put-rules/{uuid}")
module.register(GetAggregationQuery, "get-aggregation-query")
module.register(AddIOCtoIOCCollectionAction, "add_ioc_to_ioc_collection")
Expand Down
88 changes: 54 additions & 34 deletions Sekoia.io/sekoiaio/operation_center/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,15 @@
},
)

assets_base_url = "api/v2/asset-management/"
assets_v1_base_url = "api/v1/asset-management/"
assets_v2_base_url = "api/v2/asset-management/"

ListTypesForAssets = type(
"ListTypesForAssets",
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "asset-types",
"endpoint": assets_v1_base_url + "asset-types",
"query_parameters": [
"match[uuid]",
"match[name]",
Expand All @@ -331,7 +332,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "asset-types/{uuid}",
"endpoint": assets_v1_base_url + "asset-types/{uuid}",
"query_parameters": [],
},
)
Expand All @@ -341,21 +342,20 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets",
"endpoint": assets_v2_base_url + "assets",
"query_parameters": [
"limit",
"offset",
"extended",
"match[community_uuid]",
"match[uuid]",
"match[name]",
"match[category_name]",
"match[category_uuid]",
"match[type_name]",
"match[type_uuid]",
"range[criticality]",
"date[created_at]",
"date[updated_at]",
"search",
"uuids",
"community_uuids",
"type",
"category",
"source",
"reviewed",
"rule_uuid",
"criticality",
"rule_version",
"sort",
"direction",
],
Expand All @@ -367,7 +367,17 @@
(GenericAPIAction,),
{
"verb": "post",
"endpoint": assets_base_url + "assets",
"endpoint": assets_v1_base_url + "assets",
"query_parameters": [],
},
)

CreatesNewAssetV2 = type(
"CreatesNewAssetV2",
(GenericAPIAction,),
{
"verb": "post",
"endpoint": assets_v2_base_url + "assets",
"query_parameters": [],
},
)
Expand All @@ -377,7 +387,17 @@
(GenericAPIAction,),
{
"verb": "delete",
"endpoint": assets_base_url + "assets/{uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}",
"query_parameters": [],
},
)

DeletesAssetV2 = type(
"DeletesAsset",
(GenericAPIAction,),
{
"verb": "delete",
"endpoint": assets_v2_base_url + "assets/{uuid}",
"query_parameters": [],
},
)
Expand All @@ -387,7 +407,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}",
"query_parameters": [],
},
)
Expand All @@ -397,7 +417,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}/attr",
"endpoint": assets_v1_base_url + "assets/{uuid}/attr",
"query_parameters": ["limit", "offset"],
},
)
Expand All @@ -407,7 +427,7 @@
(GenericAPIAction,),
{
"verb": "post",
"endpoint": assets_base_url + "assets/{uuid}/attr",
"endpoint": assets_v1_base_url + "assets/{uuid}/attr",
"query_parameters": ["name", "value"],
},
)
Expand All @@ -417,7 +437,7 @@
(GenericAPIAction,),
{
"verb": "delete",
"endpoint": assets_base_url + "assets/{uuid}/attr/{attribute_uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}/attr/{attribute_uuid}",
"query_parameters": [],
},
)
Expand All @@ -427,7 +447,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}/attr/{attribute_uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}/attr/{attribute_uuid}",
"query_parameters": [],
},
)
Expand All @@ -437,7 +457,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}/keys",
"endpoint": assets_v1_base_url + "assets/{uuid}/keys",
"query_parameters": ["limit", "offset"],
},
)
Expand All @@ -447,7 +467,7 @@
(GenericAPIAction,),
{
"verb": "post",
"endpoint": assets_base_url + "assets/{uuid}/keys",
"endpoint": assets_v1_base_url + "assets/{uuid}/keys",
"query_parameters": ["name", "value"],
},
)
Expand All @@ -457,7 +477,7 @@
(GenericAPIAction,),
{
"verb": "delete",
"endpoint": assets_base_url + "assets/{uuid}/keys/{key_uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}/keys/{key_uuid}",
"query_parameters": [],
},
)
Expand All @@ -467,7 +487,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}/keys/{key_uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}/keys/{key_uuid}",
"query_parameters": [],
},
)
Expand All @@ -477,7 +497,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "assets/{uuid}/owners",
"endpoint": assets_v1_base_url + "assets/{uuid}/owners",
"query_parameters": ["limit", "offset"],
},
)
Expand All @@ -487,7 +507,7 @@
(GenericAPIAction,),
{
"verb": "post",
"endpoint": assets_base_url + "assets/{uuid}/owners",
"endpoint": assets_v1_base_url + "assets/{uuid}/owners",
"query_parameters": ["owners"],
},
)
Expand All @@ -497,7 +517,7 @@
(GenericAPIAction,),
{
"verb": "delete",
"endpoint": assets_base_url + "assets/{uuid}/owners/{owner_uuid}",
"endpoint": assets_v1_base_url + "assets/{uuid}/owners/{owner_uuid}",
"query_parameters": [],
},
)
Expand All @@ -507,7 +527,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "attribute-names",
"endpoint": assets_v1_base_url + "attribute-names",
"query_parameters": ["category", "type", "limit", "offset"],
},
)
Expand All @@ -517,7 +537,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "attribute-names/{uuid}",
"endpoint": assets_v1_base_url + "attribute-names/{uuid}",
"query_parameters": [],
},
)
Expand All @@ -527,7 +547,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "categories",
"endpoint": assets_v1_base_url + "categories",
"query_parameters": ["limit", "offset"],
},
)
Expand All @@ -537,7 +557,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "categories/{uuid}",
"endpoint": assets_v1_base_url + "categories/{uuid}",
"query_parameters": [],
},
)
Expand All @@ -547,7 +567,7 @@
(GenericAPIAction,),
{
"verb": "get",
"endpoint": assets_base_url + "categories/{uuid}/types",
"endpoint": assets_v1_base_url + "categories/{uuid}/types",
"query_parameters": ["limit", "offset"],
},
)
Expand Down

0 comments on commit 9e8912f

Please sign in to comment.