Skip to content

Commit 5168a9a

Browse files
Update the CTI example README (#32)
1 parent 02e0629 commit 5168a9a

File tree

5 files changed

+109
-33
lines changed

5 files changed

+109
-33
lines changed

use-cases/bookstore/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ typedb console --username=<username> --address=<address> --command="database cre
2626

2727
If you wanted to load the dataset step-by-step or using an older version of TypeDB Console, you can do the following:
2828

29-
1. In TypeDB Console, create a database - we'll use `bookstore` in this etup
30-
2. open a `schema` transaction
29+
1. In TypeDB Console, create a database - we'll use `bookstore` in this setup
30+
2. Open a `schema` transaction
3131
3. Load the `schema.tql` - the easiest is to use `source <path to schema.tql>`
3232
4. Commit the schema and verify no errors appear
3333
5. Open a `write` transaction
3434
6. Load the `data.tql` - the easiest is to use `source <path to data.tql>`
35-
7. Commit the schema
35+
7. Commit the data
3636

3737

3838
## Example Queries
Lines changed: 99 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,114 @@
1-
# Cyber threat intelligence
1+
# Cyber Threat Intelligence Platform Example
22

3-
## Introduction
3+
This example demonstrates how to use TypeDB as the database in a cyber threat intelligence context. The schema is based on
4+
STIX2.1 and models threat actors, campaigns, and their relationships.
45

5-
In this demo, you'll learn how to use TypeDB as the database in a cyber threat intelligence context. We'll cover
6-
some basic operations like listing identities and their subtypes with the help of type-inference.
6+
## Setup
77

8-
## Required knowledge
8+
Ensure you have a running TypeDB 3.0 server.
99

10-
This demo assumes knowledge of:
10+
The easiest way to load this example is using TypeDB Console. If you're using version 3.5.0, you can load the schema and data files in one line:
1111

12-
- TypeDB's transaction system.
13-
- All basic TypeQL syntax elements.
14-
- TypeDB Studio's interface.
12+
Non-interactive mode:
13+
```
14+
typedb console --username=<username> --address=<address> --command="database create-init cyber-threat-intelligence <path to schema.tql> <path to data.tql>"
15+
```
1516

16-
For more information, please see our [documentation](https://docs.typedb.com/docs/general/introduction).
17+
The `database create-init` can also be run interactively if you're already in Console!
1718

18-
General knowledge of STIX2.1 would be a plus.
19+
This example dataset is also released under the releases page so you **can load from URL**:
20+
```
21+
typedb console --username=<username> --address=<address> --command="database create-init cyber-threat-intelligence http://github.com/typedb/typedb-examples/releases/latest/download/cyber-threat-intelligence-schema.tql http://github.com/typedb/typedb-examples/releases/latest/download/cyber-threat-intelligence-data.tql"
22+
```
1923

20-
## Getting started
24+
### Manual setup
2125

22-
Start your TypeDB server and open TypeDB Studio. Make sure you are using a `schema` transaction and run the following
23-
TypeQL file:
26+
If you wanted to load the dataset step-by-step or using an older version of TypeDB Console, you can do the following:
2427

25-
```define-schema.tql```
28+
1. In TypeDB Console, create a database - we'll use `cyber-threat-intelligence` in this setup
29+
2. Open a `schema` transaction
30+
3. Load the `schema.tql` - the easiest is to use `source <path to schema.tql>`
31+
4. Commit the schema and verify no errors appear
32+
5. Open a `write` transaction
33+
6. Load the `data.tql` - the easiest is to use `source <path to data.tql>`
34+
7. Commit the data
2635

27-
Then switch to a `write` transaction and run the following:
2836

29-
```insert-data.tql```
37+
## Example queries
3038

31-
Remember to click on the green tick after running each of these scripts to commit the changes to the database.
39+
Once the dataset is loaded, you can play with some of these queries!
3240

33-
## Running the examples
41+
1. Find the campaigns that use the attack pattern designated "T1078" and the threat actor that the campaign is attributed to.
42+
```typeql
43+
match
44+
$attack-pattern isa attack-pattern, has name like "T1078";
45+
uses($attack-pattern, $campaign);
46+
attributed-to($threat-actor, $campaign);
47+
fetch {
48+
"threat actor" : $threat-actor.name,
49+
"campaign name": $campaign.name
50+
};
51+
```
3452

35-
To get started, try running the examples. They are intended to be run once each and in order, so be aware that running
36-
them more than once or out of order might generate validation errors on commit. If anything goes wrong, you can run the
37-
`insert-data.tql` script again to reset everything. You'll want to switch between `read` and `write` transactions
38-
depending on the queries in the example, and remember to commit after writes.
53+
This returns
54+
```json
55+
{
56+
"campaign name": "Salt Typhoon Campaign (2020‑2025)",
57+
"threat actor": "Salt Typhoon"
58+
}
59+
```
60+
61+
2. Find the indicators that are associated with the "Salt Typhoon" campaign, sorted by confidence.
62+
```typeql
63+
match
64+
$campaign isa campaign, has name like "Salt Typhoon";
65+
indicates($indicator, $campaign);
66+
$indicator has confidence $confidence;
67+
sort $confidence;
68+
fetch {
69+
"indicator": $indicator.name,
70+
"description": $indicator.description
71+
};
72+
```
73+
```json
74+
{
75+
"indicator": "Salt Typhoon Domain – gesturefavo.com",
76+
"description": "Domain registered under OrderBox name‑servers with privacy protection."
77+
}
78+
{
79+
"indicator": "Salt Typhoon Domain – example.com",
80+
"description": "Generic domain example used by the campaign."
81+
}
82+
{
83+
"description": "IP cluster hosting multiple campaign domains.",
84+
"indicator": "Salt Typhoon IP – 162.251.82.125"
85+
}
86+
{
87+
"indicator": "Salt Typhoon IP – 162.251.82.252",
88+
"description": "IP cluster hosting multiple campaign domains."
89+
}
90+
{
91+
"description": "IP cluster hosting multiple campaign domains.",
92+
"indicator": "Salt Typhoon IP – 162.251.82.253"
93+
}
94+
```
95+
96+
## Schema Overview
97+
98+
### Core Entities
99+
- **Attack Pattern**: Represents a specific technique or method used in an attack.
100+
- **Campaign**: Represents a series of related attacks.
101+
- **Course of Action**: Represents a recommended course of action to mitigate a threat.
102+
- **Identity**: Represents an individual, organization, or group.
103+
- **Indicator**: Represents a pattern or artifact that can be used to detect a threat.
104+
- **Threat Actor**: Represents an individual or group that poses a threat.
105+
106+
### Key Relations
107+
- `attributed-to`: Attributes a threat to an actor (e.g. a `campaign` is attributed to some `threat-actor`).
108+
- `targets`: Links a threat with its target (e.g. a `campaign` targets some `identity`).
109+
- `uses`: Links a threat with a tool it uses (e.g. a `campaign` uses some `attack-pattern`).
110+
- `indicates`: Describes that the Indicator can detect evidence of the target threat (e.g. an Attack Pattern).
111+
112+
## Sample Data
113+
114+
The sample data includes a sample campaign along with its associated attack patterns, a threat actor, and activity indicators.
File renamed without changes.
File renamed without changes.

use-cases/social-network/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ typedb console --username=<username> --address=<address> --command="database cre
2424

2525
If you wanted to load the dataset step-by-step or using an older version of TypeDB Console, you can do the following:
2626

27-
2. In TypeDB Console, create a database - we'll use `social-network` in this setup
28-
3. Open a `schema` transaction
29-
4. Load the `schema.tql` - the easiest is to use `source <path to schema.tql>`
30-
5. Commit the schema and verify no errors appear
31-
6. Open a `write` transaction
32-
7. Load the `data.tql` - the easiest is to use `source <path to data.tql>`
33-
8. Commit the schema
27+
1. In TypeDB Console, create a database - we'll use `social-network` in this setup
28+
2. Open a `schema` transaction
29+
3. Load the `schema.tql` - the easiest is to use `source <path to schema.tql>`
30+
4. Commit the schema and verify no errors appear
31+
5. Open a `write` transaction
32+
6. Load the `data.tql` - the easiest is to use `source <path to data.tql>`
33+
7. Commit the data
3434

3535

3636
## Example queries

0 commit comments

Comments
 (0)