Skip to content

Commit ae74d5d

Browse files
committed
ci: add OSCAL artifact checks in CI
Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
1 parent 49474ce commit ae74d5d

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

.github/workflows/oscal-test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: OSCAL Testing
2+
3+
permissions: {}
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- main
9+
paths:
10+
- "oscal/**"
11+
- "cmd/oscal_export/**"
12+
13+
jobs:
14+
OSCAL-Test:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v6.0.1
20+
with:
21+
persist-credentials: false
22+
- uses: actions/setup-go@v6
23+
with:
24+
go-version: stable
25+
- name: Generate OSCAL artifacts
26+
run: make oscalgenerate
27+
- name: Setup Java # this is here because oscal-cli-action below needs a java runtime
28+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e
29+
id: setup-java
30+
with:
31+
distribution: adopt
32+
java-version: 11
33+
- name: Validate OSCAL catalog
34+
uses: oscal-club/oscal-cli-action@1a210b84bc1fd6adf15c9cf0d46a51d15a3d8301 # v2.0.1
35+
with:
36+
args: validate ./artifacts/catalog.json
37+
- name: Validate OSCAL profile
38+
uses: oscal-club/oscal-cli-action@1a210b84bc1fd6adf15c9cf0d46a51d15a3d8301 # v2.0.1
39+
with:
40+
args: validate ./artifacts/profile.json
41+
- name: Validate OSCAL guidance catalog
42+
uses: oscal-club/oscal-cli-action@1a210b84bc1fd6adf15c9cf0d46a51d15a3d8301 # v2.0.1
43+
with:
44+
args: validate ./artifacts/guidance.json

cmd/oscal_export/export/export.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"fmt"
77
"os"
8+
"path/filepath"
89

910
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
1011

@@ -31,7 +32,22 @@ func Guidance(path string, args []string) error {
3132
return err
3233
}
3334

34-
oscalProfile, err := oscal.ProfileFromGuidanceDocument(&guidanceDocument, fmt.Sprintf("file://%s", *catalogOutputFile))
35+
profileDir := filepath.Dir(*profileOutputFile)
36+
catalogAbsPath, err := filepath.Abs(*catalogOutputFile)
37+
if err != nil {
38+
return fmt.Errorf("error resolving absolute path for catalog output: %w", err)
39+
}
40+
profileAbsDir, err := filepath.Abs(profileDir)
41+
if err != nil {
42+
return fmt.Errorf("error resolving absolute path for profile directory: %w", err)
43+
}
44+
relativeCatalogPath, err := filepath.Rel(profileAbsDir, catalogAbsPath)
45+
if err != nil {
46+
return fmt.Errorf("error calculating relative path: %w", err)
47+
}
48+
relativeCatalogPath = filepath.ToSlash(relativeCatalogPath)
49+
50+
oscalProfile, err := oscal.ProfileFromGuidanceDocument(&guidanceDocument, relativeCatalogPath)
3551
if err != nil {
3652
return err
3753
}

test-data/good-aigf.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,26 @@ categories:
6868
see-also:
6969
- AIR-DET-015
7070
- AIR-DET-004
71-
- AIR-PREV-005
71+
- AIR-PREV-005
72+
- id: AIR-DET-004
73+
title: Example Detective Control 004
74+
objective: Placeholder control for testing references.
75+
rationale:
76+
risks: []
77+
outcomes: []
78+
- id: AIR-DET-015
79+
title: Example Detective Control 015
80+
objective: Placeholder control for testing references.
81+
rationale:
82+
risks: []
83+
outcomes: []
84+
- id: PREV
85+
title: Preventive
86+
description: Prevention and Risk Mitigation
87+
guidelines:
88+
- id: AIR-PREV-005
89+
title: Example Preventive Control 005
90+
objective: Placeholder control for testing references.
91+
rationale:
92+
risks: []
93+
outcomes: []

0 commit comments

Comments
 (0)