Skip to content

Commit 30c6530

Browse files
authored
Merge pull request #621 from oasis-open/fix-integer-constraint
Fix integer constraint
2 parents 36217a0 + 830f5af commit 30c6530

35 files changed

+1924
-633
lines changed

.github/workflows/python-ci-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on: [push, pull_request]
66
env:
77
POSTGRES_USER: postgres
88
POSTGRES_PASSWORD: postgres
9-
POSTGRES_DB: postgres
9+
POSTGRES_DB: stix
1010

1111
jobs:
1212
test-job:
1313
runs-on: ubuntu-latest
1414

1515
services:
1616
postgres:
17-
image: postgres:11
17+
image: postgres
1818
# Provide the password for postgres
1919
env:
2020
POSTGRES_USER: postgres
@@ -34,9 +34,9 @@ jobs:
3434

3535
name: Python ${{ matrix.python-version }} Build
3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v4.2.2
3838
- name: Set up Python ${{ matrix.python-version }}
39-
uses: actions/setup-python@v2
39+
uses: actions/setup-python@v5.4.0
4040
with:
4141
python-version: ${{ matrix.python-version }}
4242
- name: Install and update essential dependencies
@@ -48,7 +48,7 @@ jobs:
4848
run: |
4949
tox
5050
- name: Upload coverage information to Codecov
51-
uses: codecov/codecov-action@v4.2.0
51+
uses: codecov/codecov-action@v5.4.0
5252
with:
5353
token: ${{ secrets.CODECOV_TOKEN }}
5454
fail_ci_if_error: false # optional (default = false)

USING_NEO4J.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Experimenting with the Neo4j graph database Python STIX DataStore
2+
3+
The Neo4j graph database Python STIX DataStore is a proof-of-concept implementation to show how to store STIX content in a graph database.
4+
5+
## Limitations:
6+
7+
As a proof-of-concept it has minimal functionality.
8+
9+
## Installing Neo4j
10+
11+
See https://neo4j.com/docs/desktop-manual/current/installation
12+
13+
This will install the neo4j desktop application, which contains the neo4j browser to view the database.
14+
15+
## Installing Neo4j python library
16+
17+
The python neo4j library used is py2neo, available in pypi at https://pypi.org/project/py2neo/. Note this library is no longer being supported and has reached the "end-of-life". A different implementation of the DataStore could be written using https://neo4j.com/docs/api/python-driver/current/.
18+
19+
## Implementation Details
20+
21+
We would like to that the folks at JHU/APL for their implementation of [STIX2NEO4J.py](https://github.com/opencybersecurityalliance/oca-iob/tree/main/STIX2NEO4J%20Converter), which this code is based on.
22+
23+
Only the DataSink (for storing STIX data) part of the DataStore object has been implemented. The DataSource part is implemented as a stub. However, the graph database can be queried using the neo4j cypher langauge within
24+
the neo4j browser.
25+
26+
The main concept behind any graphs is nodes and edges. STIX data is similar as it contains relationship objects (SROs) and node objects (SDOs, SCOs and SMOs). Additional edges are provided by STIX embedded relationships, which are expressed as properties in STIX node objects. This organization of data in STIX is a natural fit for graph models, such as neo4j.
27+
28+
The order in which STIX objects are added to the graph database is arbitrary. Therefore, when an SRO or embedded relationship is added via the DataStore, the nodes that it connects may not be present in the database, so the relationship is not added to the database, but remembered by the DataStore code as an unconnected relationship. Whenever a new node is
29+
added to the database, the unconnected relationships must be reviewed to determine if both nodes of a relationship can now be represented using an edge in the graph database.
30+
31+
Note that unless both the source and target nodes are eventually added,
32+
the relationship will not be added either.
33+
How to address this issue in the implementation has not been determined.
34+
35+
## Demonstrating a neo4j database for STIX
36+
37+
Open the neo4j desktop app and create a new project named STIX.
38+
39+
Select local DBMS on your local machine.
40+
41+
<img src="docs/diagrams/select-dbms.png" width="500" height="250">
42+
43+
Create the database.
44+
45+
<img src="docs/diagrams/create-dbms.png" width="500" height="300">
46+
47+
Start the database.
48+
49+
<img src="docs/diagrams/start-dbms.png" width="500" height="120">
50+
51+
python demo.py \<STIX bundle file\> is used populate a local neo4j database, which can be viewed using the neo4j browser.
52+
A sample bundle file bundle--21531315-283d-4604-8501-4b7166e58c84.json is provided in the docs directory.
53+
54+
Open the neo4j browser to view the database.
55+
56+
<img src="docs/diagrams/open-browser.png" width="500" height="250">
57+
58+
Query using the cypher language.
59+
60+
<img src="docs/diagrams/query-for-incident.png" width="750" height="450">
61+
62+
Left-clicking on a node gives you a choice of adding all related nodes and edges, removing the node and its edges from the display, or locking the node position.
63+
64+
<img src="docs/diagrams/node-actions.png" width="500" height="320">
65+
66+
Remove the report object node for a better view of the graph.
67+
68+
<img src="docs/diagrams/dont-show-node-and-edges.png" width="750" height="450">
69+
70+
Explore the graph.
71+
72+
<img src="docs/diagrams/exploring-the-graph.png" width="750" height="400">
73+
74+
View the node properties, by mousing-over any node.
75+
76+
<img src="docs/diagrams/node-properties.png" width="750" height="400">

docs/diagrams/create-dbms.png

59.3 KB
Loading
193 KB
Loading
262 KB
Loading

docs/diagrams/node-actions.png

64.8 KB
Loading

docs/diagrams/node-properties.png

265 KB
Loading

docs/diagrams/open-browser.png

88.3 KB
Loading
126 KB
Loading

docs/diagrams/select-dbms.png

59 KB
Loading

0 commit comments

Comments
 (0)