Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Sekoia support
url: https://docs.sekoia.io/getting_started/support_and_resources/
about: For a problem with your Sekoia account or data, contact support rather than opening a public issue.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/playbook-template-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Broken playbook template
description: A template from the playbook editor fails or does not do what it says
labels: ["playbook-template", "bug"]
body:
- type: input
id: template
attributes:
label: Template
description: Its name in the editor, or its file under playbooks/templates/.
validations:
required: true
- type: textarea
id: what-happens
attributes:
label: What happens
description: The node that fails and its error message. Remove any customer data before posting.
validations:
required: true
- type: textarea
id: expected
attributes:
label: What you expected
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/playbook-template-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Playbook template idea
description: Suggest a playbook template, or tell us you are building one
labels: ["playbook-template", "idea"]
body:
- type: markdown
attributes:
value: |
Templates appear in the Sekoia playbook editor under **Start from a template**, for every customer.
Ideas with a clear use case and the integrations they need are the easiest to pick up, by us or by anyone in the community.
- type: textarea
id: use-case
attributes:
label: Use case
description: 'What should happen, when, and for whom? Example: "When an alert on a phishing rule is created, check the sender''s domain and comment the verdict."'
validations:
required: true
- type: input
id: integrations
attributes:
label: Integrations
description: The products the playbook talks to (e.g. Microsoft Entra ID, Jira, VirusTotal).
- type: dropdown
id: trigger
attributes:
label: Trigger
options:
- Manual, from an alert
- Alert created or updated
- Case created or updated
- Scheduled (cron)
- Webhook
- Not sure
- type: dropdown
id: contribution
attributes:
label: Will you build it?
options:
- Yes, I will open a pull request
- I can help test it
- No, it is an idea for someone else
validations:
required: true
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## What this adds or fixes

<!-- One or two sentences: the use case, and who it helps. -->

## If you add or change a playbook template

- [ ] I built and ran this playbook in a Sekoia community, then exported it with `playbooks/tools/export_template.py`
- [ ] The description says what the playbook does and what it needs (integration, account, licence, fields in the events)
- [ ] The trigger is right for the use case (manual from an alert, alert created, cron, webhook)
- [ ] `python playbooks/tools/check_templates.py --automation-library <path>` passes locally
- [ ] A screenshot of the playbook, or of a successful run, is attached below

<!-- Every template merged on main reaches all Sekoia customers at the next deployment of the playbook service. -->
60 changes: 60 additions & 0 deletions .github/workflows/playbook-templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Playbook templates

on:
pull_request:
paths:
- "playbooks/**"
- ".github/workflows/playbook-templates.yml"
push:
branches: [main]
paths:
- "playbooks/**"
# An action can be removed or changed in automation-library after a template was merged
schedule:
- cron: "23 6 * * 1" # Monday, 06:23 UTC
workflow_dispatch:

permissions:
contents: read

jobs:
check:
name: Check playbook templates
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out the repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"

- name: Install the checker dependencies
run: pip install "jsonschema==4.26.0" "jinja2==3.1.6"

# The catalogue the platform runs: the production branch of automation-library, manifests only
- name: Fetch the automation-library manifests
run: |
git clone --quiet --depth 1 --filter=blob:none --sparse --branch production \
https://github.com/SEKOIA-IO/automation-library.git "$RUNNER_TEMP/automation-library"
git -C "$RUNNER_TEMP/automation-library" sparse-checkout set --no-cone \
'/*/manifest.json' '/*/action_*.json' '/*/trigger_*.json'

- name: Check the templates
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "pull_request" ]; then
# Only the files of the pull request block it: an older bug on main is reported as a warning
python playbooks/tools/check_templates.py --automation-library "$RUNNER_TEMP/automation-library" \
--base "origin/${BASE_REF}"
else
python playbooks/tools/check_templates.py --automation-library "$RUNNER_TEMP/automation-library"
fi
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ playbooks and much more to help you make the most of the capabilities of the Sek

For questions and feedback, please contact support@sekoia.io

## Playbook template
## Playbook templates

You can add playbook template in the folder: "playbooks/templates".
Your template must NOT contain the fields:
"trigger_configuration_uuid"
"module_configuration_uuid"
"community_uuid"
Your need to add your new template file to the list of template in the file:
"playbooks/templates/playbooks.json"
Playbook templates appear in the Sekoia playbook editor under **Start from a template**, for every customer.
To contribute one, read [playbooks/README.md](playbooks/README.md): build and run it in Sekoia, export it, check it, open a pull request.
61 changes: 61 additions & 0 deletions playbooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Playbook templates

The templates in [`templates/`](templates/) appear in the Sekoia playbook editor, under **Start from a template** on a new playbook, for every customer in every region. They are the fastest way to share a playbook that works: an enrichment, a notification, a response to a type of alert.

A template merged on `main` is published with the next release of the Sekoia playbook service. Removing a file removes the template from the editor. Playbooks already created from it keep their own copy and are not affected.

## Contribute a template

1. **Build and run the playbook in your Sekoia community.** A template that never ran is not accepted.
2. **Export it into this repository.** The UUID of the playbook is the last part of its address in Sekoia (`.../playbooks/<uuid>`).

```bash
SEKOIA_API_KEY=<key> python playbooks/tools/export_template.py <playbook_uuid> enrich_alert_with_example.json
```

The API key needs the **View playbooks** permission. Outside FRA1, add `--base-url` with the API URL of your region (listed in the script and in the [API documentation](https://docs.sekoia.io/developer/api/)). The script removes the accounts of your community (module and trigger configurations), as Sekoia does when it turns a playbook into a template, and gives the file a new UUID.
3. **Complete the file.** Write the description, add tags, and replace every value specific to your environment (URL, project key, IOC collection...) with `_to_update_`.
4. **Check it.**

```bash
pip install "jsonschema==4.26.0" "jinja2==3.1.6"
git clone --depth 1 --filter=blob:none --sparse --branch production \
https://github.com/SEKOIA-IO/automation-library.git /tmp/automation-library
git -C /tmp/automation-library sparse-checkout set --no-cone '/*/manifest.json' '/*/action_*.json' '/*/trigger_*.json'
python playbooks/tools/check_templates.py --automation-library /tmp/automation-library
```
5. **Open a pull request** and fill in the checklist. The same check runs on the pull request.

Not ready to build it? [Open an idea](https://github.com/SEKOIA-IO/Community/issues/new?template=playbook-template-request.yml): someone else may pick it up.

## What makes a good template

- **One use case, named by what it does.** "Enrich an alert with AbuseIPDB", not "AbuseIPDB playbook".
- **A description that says what it does and what it needs**: the integration and its account, a licence if any, the event fields it reads.
- **Published actions only.** Every action and trigger must exist on the `production` branch of [automation-library](https://github.com/SEKOIA-IO/automation-library). If your integration is not released yet, open the template pull request after its release.
- **Event fields that exist.** Read fields of the Sekoia event taxonomy (`source.ip`, `url.original`, `file.hash.sha256`...). A field no intake produces makes every run fail.
- **Nothing private.** No account, API key, URL or name from your environment. Mark what the reader must change with `_to_update_` and say so in the description.
- **Tags readers filter on.** Reuse existing tags, start them with a capital letter, and add the vendor name (e.g. `Alerts`, `Enrichment`, `Jira`).

## What the check verifies

Errors block the merge. They are what the platform refuses when it loads the template, or what makes every run fail:

- the file is valid JSON with a `uuid` (unique in the repository), a `name` and `nodes`;
- no node carries a module or trigger configuration;
- node ids are plain numbers, and every output leads to a node that exists;
- every action and trigger exists in automation-library (or is built into the platform, see [`tools/builtin_catalogue.json`](tools/builtin_catalogue.json)), with its own module;
- the arguments of each action match its definition, required arguments included (a Jinja value such as `{{ node.1.uuid }}` is accepted for any type);
- operators are well formed, Jinja is valid, and every `node.N` a field reads exists.

Warnings do not block: empty description, unreachable node, a branch that matches no case or no output of its action, a field read from a node that its action does not declare in its result (`node.1.first_seen` instead of `first_seen_at`), tag spelling. In a pull request, only the files it touches are reported in detail: a problem already on `main` in another file is summed up in one line and does not block it.

The check is a pre-flight. The platform runs its own validation when it loads the templates.

## Review

Pull requests on `playbooks/` are reviewed by the Sekoia playbook team. Reviewers look at what the check cannot see: does the playbook do what its description says, for a real use case?

## Change or remove a template

Open a pull request on the file. Keep its `uuid`: the platform updates the published template in place. A file that no longer passes the platform validation is removed from the editor at the next deployment, which is why the check runs on every change.
Loading