Server.Utils.SaveFavoriteFlow
Type: Server
Saves a collection configuration spec as a named favorite template for reuse across client or server collections.
Users may collect various artifacts from hosts. Sometimes it might take a bit of effort to set up and configure just the right combination of parameters and artifacts to collect. This artifact allows the user to save the collection into a Favorites selection, which may be used in future.
An example of a Favorites spec is
[{"artifact":"Windows.KapeFiles.Targets", "parameters":{"env":[{"key":"EventLogs", "value":"Y"}]}}]
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Specs |
string | The collection request that will be recreated encoded as a JSON dict. | |
FlowId |
string | If provided we copy the spec from this flow. | |
ClientId |
string | If provided we copy the spec from this client. | |
Name |
string | A name for this collection template | |
Description |
string | A description for the template. | |
Type |
choices | CLIENT |
The type of favorites to save. |
AllUsers |
bool | If set, add the favorite to all users in all orgs. |
Source
Defined in artifacts/definitions/Server/Utils/SaveFavoriteFlow.yaml.
name: Server.Utils.SaveFavoriteFlow
description: |
Saves a collection configuration spec as a named favorite template
for reuse across client or server collections.
Users may collect various artifacts from hosts. Sometimes it might
take a bit of effort to set up and configure just the right
combination of parameters and artifacts to collect. This artifact
allows the user to save the collection into a Favorites selection,
which may be used in future.
An example of a Favorites spec is
` ` `json
[{"artifact":"Windows.KapeFiles.Targets", "parameters":{"env":[{"key":"EventLogs", "value":"Y"}]}}]
` ` `
type: SERVER
parameters:
- name: Specs
description: The collection request that will be recreated encoded as a JSON dict.
- name: FlowId
description: If provided we copy the spec from this flow.
- name: ClientId
description: If provided we copy the spec from this client.
- name: Name
description: A name for this collection template
- name: Description
description: A description for the template.
- name: Type
description: The type of favorites to save.
type: choices
default: CLIENT
choices:
- CLIENT
- SERVER
- CLIENT_EVENT
- SERVER_EVENT
- name: AllUsers
type: bool
description: If set, add the favorite to all users in all orgs.
sources:
- query: |
LET _Flow = SELECT request FROM flows(
client_id=ClientId, flow_id=FlowId)
LET Specs <= if(condition=FlowId AND ClientId,
then=_Flow[0].request.specs, else=Specs)
LET AddToAllOrgs = SELECT * FROM foreach(
row={
SELECT name, org_id
FROM gui_users(all_orgs=TRUE)
}, query={
SELECT * FROM query(query={
SELECT favorites_save(type=Type,
description=Description,
name=Name,
specs=Specs)
FROM scope()
},
org_id=org_id,
runas=name,
env=dict(
Specs=Specs,
Name=Name, Type=Type,
Description=Description))
})
LET AddToOneUser = SELECT favorites_save(
name=Name,
description=Description,
specs=Specs,
type=Type) AS Favorite
FROM scope()
LET DoIt = SELECT * FROM if(condition=AllUsers,
then=AddToAllOrgs, else=AddToOneUser)
SELECT * FROM if(condition=Specs, then=DoIt,
else={
SELECT *
FROM scope()
WHERE log(message="No specs to save!", level="ERROR") AND FALSE
})