Skip to content

Commit b95ed65

Browse files
Revert "feat!: separate CIM data models into standalone splunk-cim-models package [BREAKING]" (#948)
Reverts #946
1 parent 49eb1af commit b95ed65

18 files changed

Lines changed: 2518 additions & 760 deletions

.github/workflows/build-test-release.yml

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ jobs:
7474
submodules: true
7575
- name: Install dependencies
7676
run: |
77-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
78-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
7977
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
8078
poetry install
8179
poetry run pytest -v tests/unit
@@ -101,8 +99,6 @@ jobs:
10199
run: |
102100
mkdir test-results-${{ matrix.splunk.version }}
103101
- name: Test
104-
env:
105-
GH_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
106102
run: |
107103
export SPLUNK_APP_PACKAGE=./tests/e2e/addons/TA_fiction_indextime
108104
export SPLUNK_ADDON=TA_fiction_indextime
@@ -163,105 +159,14 @@ jobs:
163159
with:
164160
python-version: 3.7
165161
- run: |
166-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
167-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
168162
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
169163
poetry install
170164
poetry run pytest -v --splunk-version=${{ matrix.splunk.version }} -m docker -m ${{ matrix.test-marker }} tests/e2e
171-
env:
172-
GH_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
173-
174-
# ---------------------------------------------------------------------------
175-
# Validate PSA against multiple splunk-cim-models package versions.
176-
#
177-
# Matrix axes:
178-
# splunk – every supported Splunk version (from meta job)
179-
# cim-models – every package git ref listed below
180-
#
181-
# How to add a new CIM models release:
182-
# 1. Append a new entry to the cim-models list with the git ref (branch
183-
# or tag) and a short human-readable label.
184-
# 2. The matrix will automatically run the splunk_cim_model e2e test
185-
# for each (Splunk version, CIM models version) combination.
186-
#
187-
# Only the splunk_cim_model marker is used here because the other CIM
188-
# e2e markers (splunk_app_cim_fiction, splunk_app_cim_broken) always pass
189-
# --splunk-dm-path with custom fiction models and are therefore unaffected
190-
# by the installed splunk-cim-models version.
191-
# ---------------------------------------------------------------------------
192-
test-cim-models-versions:
193-
needs:
194-
- meta
195-
- pre-commit
196-
- fossa-scan
197-
- compliance-copyrights
198-
- test-splunk-unit
199-
runs-on: ubuntu-22.04
200-
strategy:
201-
fail-fast: false
202-
matrix:
203-
splunk: ${{ fromJson(needs.meta.outputs.matrix_supportedSplunk) }}
204-
cim-models:
205-
- ref: "v1"
206-
label: "1.x"
207-
- ref: "v2"
208-
label: "2.x"
209-
# Add future releases here, e.g.:
210-
# - ref: "v3"
211-
# label: "3.x"
212-
name: "CIM models ${{ matrix.cim-models.label }} / Splunk ${{ matrix.splunk.version }}"
213-
steps:
214-
- uses: actions/checkout@v4
215-
with:
216-
submodules: true
217-
- uses: actions/setup-python@v5
218-
with:
219-
python-version: "3.7"
220-
- name: Install PSA with CIM models ${{ matrix.cim-models.label }}
221-
env:
222-
GH_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
223-
run: |
224-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf https://github.com
225-
git config --global --add url."https://${{ secrets.GH_TOKEN_ADMIN }}@github.com".insteadOf ssh://git@github.com
226-
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
227-
poetry install
228-
# Override the dev-dependency CIM models with the matrix version.
229-
# Using pip inside the Poetry venv so the pytester subprocess sees
230-
# the same environment.
231-
poetry run pip install \
232-
"git+https://github.com/splunk/psa-cim-models.git@${{ matrix.cim-models.ref }}"
233-
- name: Verify splunk-cim-models ${{ matrix.cim-models.label }}
234-
run: |
235-
poetry run python - <<'EOF'
236-
import splunk_cim_models as scm
237-
print("DATA_MODELS_PATH:", scm.DATA_MODELS_PATH)
238-
print("CIM versions available:", list(scm.datamodels.keys()))
239-
EOF
240-
- name: Run CIM compatibility e2e tests
241-
env:
242-
GH_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
243-
run: |
244-
# splunk_app_cim_fiction uses --splunk-dm-path with local fiction
245-
# data models, so expected test outcomes are identical across all
246-
# splunk-cim-models versions. It still exercises all PSA import
247-
# paths (COMMON_FIELDS_PATH, DATAMODEL_SCHEMA_PATH, datamodels) so
248-
# an incompatible package version will surface as a collection or
249-
# runtime error rather than a wrong-field assertion.
250-
#
251-
# splunk_cim_model (real Change/Network_Traffic models) is left to
252-
# test-splunk-matrix, which always uses the default v2 dev
253-
# dependency and asserts version-specific field outcomes.
254-
poetry run pytest -v \
255-
--splunk-version=${{ matrix.splunk.version }} \
256-
-m docker \
257-
-m splunk_app_cim_fiction \
258-
tests/e2e
259165
260166
publish:
261167
needs:
262168
- test-splunk-external
263169
- test-splunk-matrix
264-
- test-cim-models-versions
265170
runs-on: ubuntu-22.04
266171
steps:
267172
- uses: actions/checkout@v4

.licenserc.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ header:
3838
- "pytest_splunk_addon/.ignore_splunk_internal_errors"
3939
- "pytest_splunk_addon/docker_class.py"
4040
- "deps"
41-
- "splunk-cim-models/**"

docker-compose-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ services:
3232
- sc4s
3333
volumes:
3434
- results:/work/test-results
35-
environment:
36-
- GH_TOKEN
3735

3836
sc4s:
3937
image: ghcr.io/splunk/splunk-connect-for-syslog/container2:latest

docs/cim_tests.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,12 @@
22

33
## Overview
44

5-
The CIM tests are written with a purpose of testing the compatibility of the add-on with CIM Data Models.
5+
The CIM tests are written with a purpose of testing the compatibility of the add-on with CIM Data Models (Based on Splunk_SA_CIM 4.15.0).
66
An add-on is said to be CIM compatible if it fulfils the following two criteria:
77

8-
1. The add-on extracts all the fields with valid values, which are marked as required by the [Data Model Definitions](https://github.com/splunk/psa-cim-models).
8+
1. The add-on extracts all the fields with valid values, which are marked as required by the [Data Model Definitions](https://github.com/splunk/pytest-splunk-addon/tree/main/pytest_splunk_addon/standard_lib/data_models).
99
2. Any event for the add-on is not mapped with more than one data model.
1010

11-
## CIM Data Models Package (`splunk-cim-models`)
12-
13-
CIM data model definitions are provided by the separate
14-
[`splunk-cim-models`](https://github.com/splunk/psa-cim-models) package.
15-
This lets you update or pin CIM definitions independently of `pytest-splunk-addon` itself.
16-
17-
**Install for CIM testing:**
18-
19-
```console
20-
pip install splunk-cim-models
21-
```
22-
23-
Or, during development, install the latest from the repository:
24-
25-
```console
26-
pip install git+https://github.com/splunk/psa-cim-models.git@v2
27-
```
28-
29-
The package exposes:
30-
31-
| Symbol | Description |
32-
|---|---|
33-
| `DATA_MODELS_PATH` | Path to the directory containing the built-in CIM JSON data model files |
34-
| `COMMON_FIELDS_PATH` | Path to `CommonFields.json` (fields forbidden in props/search) |
35-
| `DATAMODEL_SCHEMA_PATH` | Path to `DatamodelSchema.json` (JSON schema for validating custom data model files) |
36-
| `datamodels` | Dict mapping CIM version strings to recommended fields per model |
37-
38-
If `splunk-cim-models` is not installed, any test run that exercises CIM functionality
39-
will raise an `ImportError` with a message pointing to the package.
40-
4111
______________________________________________________________________
4212

4313
To generate test cases only for CIM compatibility, append the following marker to pytest command:
@@ -60,7 +30,7 @@ To generate test cases only for CIM compatibility, append the following marker t
6030
**Workflow:**
6131

6232
- Plugin parses tags.conf to get a list of tags for each eventtype.
63-
- Plugin parses all the [supported datamodels](https://github.com/splunk/psa-cim-models).
33+
- Plugin parses all the [supported datamodels](https://github.com/splunk/pytest-splunk-addon/tree/main/pytest_splunk_addon/standard_lib/data_models).
6434
- Then it gets a list of the datasets mapped with an eventtype.
6535
- Generates test case for each eventtype.
6636

@@ -109,11 +79,11 @@ To generate test cases only for CIM compatibility, append the following marker t
10979

11080
**Workflow:**
11181

112-
- Plugin collects the list of not_allowed_in_search fields from mapped datasets and [CommonFields.json](https://github.com/splunk/psa-cim-models/blob/v2/splunk_cim_models/CommonFields.json).
82+
- Plugin collects the list of not_allowed_in_search fields from mapped datasets and [CommonFields.json](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/standard_lib/cim_tests/CommonFields.json).
11383
- Using search query the test case verifies if not_allowed_in_search fields are populated in search or not.
11484

11585
> **_NOTE:_**
116-
[CommonFields.json](https://github.com/splunk/psa-cim-models/blob/v2/splunk_cim_models/CommonFields.json) contains fields which are automatically provided by asset and identity correlation features of applications like Splunk Enterprise Security.
86+
[CommonFields.json](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/standard_lib/cim_tests/CommonFields.json) contains fields which are automatically provided by asset and identity correlation features of applications like Splunk Enterprise Security.
11787

11888

11989
**4. Testcase for all not_allowed_in_props fields**

docs/contributing.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,6 @@ To install currently checked out version of pytest-splunk-addon use:
1818
$ poetry install
1919
```
2020

21-
This installs `splunk-cim-models` automatically as a dev dependency (from the `v2` branch of
22-
[psa-cim-models](https://github.com/splunk/psa-cim-models)). In CI or when installing from
23-
PyPI, install `splunk-cim-models` separately before running CIM tests:
24-
25-
```
26-
$ pip install splunk-cim-models
27-
```
28-
29-
### Working with `splunk-cim-models`
30-
31-
CIM data model definitions live in the separate
32-
[`splunk-cim-models`](https://github.com/splunk/psa-cim-models) package.
33-
PSA imports four symbols from it:
34-
35-
| Symbol | Used by |
36-
|---|---|
37-
| `DATA_MODELS_PATH` | `app_test_generator.py` — default path for `--splunk_dm_path` |
38-
| `COMMON_FIELDS_PATH` | `cim_tests/test_generator.py` — fields forbidden in props/search |
39-
| `DATAMODEL_SCHEMA_PATH` | `cim_tests/json_schema.py` — JSON schema for custom data models |
40-
| `datamodels` | `splunk.py` — CIM version → recommended fields map |
41-
42-
To update CIM definitions locally without waiting for a `splunk-cim-models` release:
43-
44-
```bash
45-
# Edit files under splunk-cim-models/ then reinstall editable
46-
pip install -e path/to/psa-cim-models/
47-
48-
# Verify
49-
python -c "from splunk_cim_models import datamodels; print(list(datamodels.keys()))"
50-
```
51-
52-
After editing, run the unit tests to confirm nothing is broken:
53-
54-
```bash
55-
poetry run pytest -v tests/unit
56-
```
5721

5822
### Unit tests
5923

docs/how_to_use.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,6 @@ def splunk_setup(splunk):
460460

461461
How can this be achieved :
462462

463-
- Make json representation of the data models, which satisfies the [DatamodelSchema](https://github.com/splunk/psa-cim-models/blob/v2/splunk_cim_models/DatamodelSchema.json) provided by the `splunk-cim-models` package.
464-
- Provide the path to the directory having all the data models by adding `--splunk_dm_path path_to_dir` to the pytest command.
465-
- The test cases will now be generated for the data models provided to the plugin and not for the [default data models](https://github.com/splunk/psa-cim-models/tree/v2/splunk_cim_models/data_models) bundled in `splunk-cim-models`.
466-
467-
> **_NOTE:_** CIM data model definitions are provided by the [`splunk-cim-models`](https://github.com/splunk/psa-cim-models) package. Install it separately before running CIM tests:
468-
>
469-
> ```console
470-
> pip install splunk-cim-models
471-
> ```
463+
- Make json representation of the data models, which satisfies this [DataModelSchema](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/cim_tests/DatamodelSchema.json).
464+
- Provide the path to the directory having all the data models by adding `--splunk_dm_path path_to_dir` to the pytest command
465+
- The test cases will now be generated for the data models provided to the plugin and not for the [default data models](https://github.com/splunk/pytest-splunk-addon/tree/main/pytest_splunk_addon/data_models).

docs/index.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ which allows the user to test [knowledge objects](https://docs.splunk.com/Splexi
88
- Splunk App or Add-on package
99
- Splunk instance with App or Add-on installed (Not required if using Docker)
1010
- Docker (Not required if using external Splunk instance)
11-
- [`splunk-cim-models`](https://github.com/splunk/psa-cim-models) — required for [CIM Compatibility Tests](./cim_tests.md) (not installed automatically)
1211

1312
## Support
1413

@@ -23,17 +22,6 @@ pytest-splunk-addon can be installed via pip from PyPI:
2322
pip3 install pytest-splunk-addon
2423
```
2524

26-
To run **CIM compatibility tests** you also need the CIM data models package:
27-
28-
```console
29-
pip3 install splunk-cim-models
30-
```
31-
32-
`splunk-cim-models` is versioned independently of `pytest-splunk-addon` so that CIM
33-
definitions can be updated without a full PSA release. See the
34-
[CIM Compatibility Tests](./cim_tests.md) page for details on how the two packages
35-
interact and how to pin or override data model definitions.
36-
3725
## Features
3826

3927
The pytest-splunk-addon works by dynamically generating different types of tests for Splunk apps and add-ons by parsing their configuration files. Specifically, it looks at the .conf files in the provided Splunk app/add-on to create:

entrypoint.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ pyenv local 3.7.8
99
curl -sSL https://install.python-poetry.org | python - --version 1.5.1
1010
export PATH="/root/.local/bin:$PATH"
1111
source ~/.poetry/env
12-
if [ -n "$GH_TOKEN" ]; then
13-
git config --global --add url."https://$GH_TOKEN@github.com".insteadOf https://github.com
14-
git config --global --add url."https://$GH_TOKEN@github.com".insteadOf ssh://git@github.com
15-
fi
1612
sleep 15
1713
poetry install
1814
exec poetry run pytest -vv $@

0 commit comments

Comments
 (0)