Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update api url and scan config example #543

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
8 changes: 4 additions & 4 deletions docs/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ If we want to report results to the VMClarity backend, we need to create asset a
## Reporting results to VMClarity backend:

```
ASSET_ID=$(./cli/bin/vmclarity-cli asset-create --file assets/dir-asset.json --server http://localhost:8888/api) --jsonpath {.id}
ASSET_SCAN_ID=$(./cli/bin/vmclarity-cli asset-scan-create --asset-id $ASSET_ID --server http://localhost:8888/api) --jsonpath {.id}
./cli/bin/vmclarity-cli scan --config ~/testConf.yaml --server http://localhost:8888/api --asset-scan-id $ASSET_SCAN_ID
ASSET_ID=$(./cli/bin/vmclarity-cli asset-create --file assets/dir-asset.json --server http://localhost:8080/api) --jsonpath {.id}
ASSET_SCAN_ID=$(./cli/bin/vmclarity-cli asset-scan-create --asset-id $ASSET_ID --server http://localhost:8080/api) --jsonpath {.id}
./cli/bin/vmclarity-cli scan --config ~/testConf.yaml --server http://localhost:8080/api --asset-scan-id $ASSET_SCAN_ID
```

Using one-liner:
```
./cli/bin/vmclarity-cli asset-create --file docs/assets/dir-asset.json --server http://localhost:8888/api --update-if-exists --jsonpath {.id} | xargs -I{} ./cli/bin/vmclarity-cli asset-scan-create --asset-id {} --server http://localhost:8888/api --jsonpath {.id} | xargs -I{} ./cli/bin/vmclarity-cli scan --config ~/testConf.yaml --server http://localhost:8888/api --asset-scan-id {}
./cli/bin/vmclarity-cli asset-create --file docs/assets/dir-asset.json --server http://localhost:8080/api --update-if-exists --jsonpath {.id} | xargs -I{} ./cli/bin/vmclarity-cli asset-scan-create --asset-id {} --server http://localhost:8080/api --jsonpath {.id} | xargs -I{} ./cli/bin/vmclarity-cli scan --config ~/testConf.yaml --server http://localhost:8080/api --asset-scan-id {}
```
34 changes: 19 additions & 15 deletions docs/scanConfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
{
"name": "test",
"scanFamiliesConfig": {
"sbom": {
"enabled": true
},
"vulnerabilities": {
"enabled": true
},
"exploits": {
"enabled": true
}
"name": "test",
"scanTemplate": {
"scope": "contains(assetInfo.tags, '{\"key\":\"scanconfig\",\"value\":\"test\"}')",
"assetScanTemplate": {
"scanFamiliesConfig": {
"sbom": {
"enabled": true
},
"scheduled": {
"cronLine": "0 */4 * * *",
"operationTime": "2023-01-20T15:46:18+00:00"
"vulnerabilities": {
"enabled": true
},
"scope": ""
"exploits": {
"enabled": true
}
}
}
},
"scheduled": {
"cronLine": "0 */4 * * *",
"operationTime": "2023-01-20T15:46:18+00:00"
}
}
6 changes: 3 additions & 3 deletions docs/test_e2e.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ DOCKER_REGISTRY=<your docker registry> make push-docker
3. While ssh'd into the VMClarity server run

```
curl -X POST http://localhost:8888/api/scanConfigs -H 'Content-Type: application/json' -d @scanConfig.json
curl -X POST http://localhost:8080/api/scanConfigs -H 'Content-Type: application/json' -d @scanConfig.json
```

4. Check VMClarity logs to ensure that everything is performing as expected
Expand All @@ -105,7 +105,7 @@ DOCKER_REGISTRY=<your docker registry> make push-docker
* Get scans:

```
curl -X GET http://localhost:8888/api/scans
curl -X GET http://localhost:8080/api/scans
```

After the operationTime in the scan config created above there should be a new
Expand All @@ -121,5 +121,5 @@ DOCKER_REGISTRY=<your docker registry> make push-docker
* Get asset scans:

```
curl -X GET http://localhost:8888/api/assetScans
curl -X GET http://localhost:8080/api/assetScans
```
40 changes: 22 additions & 18 deletions docs/testplans/abort-scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,42 @@ Create Scan Configuration file
cat <<EOF > scanconfig.json
{
"name": "test",
"scanFamiliesConfig": {
"sbom": {
"enabled": true
},
"vulnerabilities": {
"enabled": true
},
"exploits": {
"enabled": true
}
"scanTemplate": {
"scope": "contains(assetInfo.tags, '{\"key\":\"scanconfig\",\"value\":\"test\"}')",
"assetScanTemplate": {
"scanFamiliesConfig": {
"sbom": {
"enabled": true
},
"vulnerabilities": {
"enabled": true
},
"exploits": {
"enabled": true
}
}
}
},
"scheduled": {
"cronLine": "0 */4 * * *",
"operationTime": "2023-01-20T15:46:18+00:00"
},
"scope": "contains(assetInfo.tags, '{\"key\":\"ScanConfig\",\"value\":\"test\"}')"
}
}
EOF
```

Apply Scan Configuration to API

```shell
curl -sSf -X POST 'http://localhost:8888/api/scanConfigs' -H 'Content-Type: application/json' \
curl -sSf -X POST 'http://localhost:8080/api/scanConfigs' -H 'Content-Type: application/json' \
-d @scanconfig.json \
| jq -r -e '.id' > scanconfig.id
```

Get Scan Configuration object from API

```shell
curl -sSf -X GET 'http://localhost:8888/api/scanConfigs/'"$(cat scanconfig.id)"'' \
curl -sSf -X GET 'http://localhost:8080/api/scanConfigs/'"$(cat scanconfig.id)"'' \
| jq -r -e '.' > scanconfig.api.json
```

Expand All @@ -48,9 +52,9 @@ curl -sSf -X GET 'http://localhost:8888/api/scanConfigs/'"$(cat scanconfig.id)"'
Start Scan using Scan Config

```shell
jq -r -e '{maxParallelScanners, name, scanFamiliesConfig, scheduled, scope} | .scheduled.operationTime = (now|todate)' \
jq -r -e '{maxParallelScanners, name, scanTemplate, scheduled} | .scheduled.operationTime = (now|todate)' \
scanconfig.api.json \
| curl -sSf -X PUT -H 'Content-Type: application/json' 'http://localhost:8888/api/scanConfigs/'"$(cat scanconfig.id)"'' \
| curl -sSf -X PUT -H 'Content-Type: application/json' 'http://localhost:8080/api/scanConfigs/'"$(cat scanconfig.id)"'' \
-d @-
```

Expand All @@ -59,7 +63,7 @@ jq -r -e '{maxParallelScanners, name, scanFamiliesConfig, scheduled, scope} | .s
Get ongoing Scan from API using ScanConfig id

```shell
curl -sSf -G 'http://localhost:8888/api/scans' \
curl -sSf -G 'http://localhost:8080/api/scans' \
--data-urlencode "\$filter=scanConfig/id eq '$(cat scanconfig.id)' and state ne 'Done' and state ne 'Failed'" \
| jq -r -e '.items | first' > scan.api.json
```
Expand All @@ -77,7 +81,7 @@ EOF
```shell
jq -r -e '.id' scan.api.json > scan.id \
&& curl -sSf -X PATCH -H 'Content-Type: application/json' \
"http://localhost:8888/api/scans/$(cat scan.id)" \
"http://localhost:8080/api/scans/$(cat scan.id)" \
-d @scan-aborted.json \
| jq -r -e '.' > scan-aborted.api.json
```
Loading