Skip to content

Commit 6e3f39f

Browse files
committed
# This is a combination of 16 commits.
# This is the 1st commit message: docs: add CI workflows to contributing guide # This is the commit message #2: docs: applying suggestions from code review for authoring CI workflows Co-authored-by: Jennifer Power <jpower@redhat.com> # This is the commit message #3: fix: run the paths-filter step in its own job (#370) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> # This is the commit message #4: build(deps-dev): bump mkdocs-material from 9.5.37 to 9.5.43 (#377) Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.37 to 9.5.43. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](squidfunk/mkdocs-material@9.5.37...9.5.43) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #5: build(deps-dev): bump virtualenv from 20.26.5 to 20.27.1 (#379) Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.26.5 to 20.27.1. - [Release notes](https://github.com/pypa/virtualenv/releases) - [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst) - [Commits](pypa/virtualenv@20.26.5...20.27.1) --- updated-dependencies: - dependency-name: virtualenv dependency-type: indirect update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #6: build(deps): bump argcomplete from 3.5.0 to 3.5.1 (#371) Bumps [argcomplete](https://github.com/kislyuk/argcomplete) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/kislyuk/argcomplete/releases) - [Changelog](https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst) - [Commits](kislyuk/argcomplete@v3.5.0...v3.5.1) --- updated-dependencies: - dependency-name: argcomplete dependency-type: indirect update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #7: build(deps): bump httpcore from 1.0.5 to 1.0.6 (#373) Bumps [httpcore](https://github.com/encode/httpcore) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/encode/httpcore/releases) - [Changelog](https://github.com/encode/httpcore/blob/master/CHANGELOG.md) - [Commits](encode/httpcore@1.0.5...1.0.6) --- updated-dependencies: - dependency-name: httpcore dependency-type: indirect update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #8: docs: add authoring tutorial (#375) * docs: add authoring tutorial * docs: fix typos and add statement around pull request best practices # This is the commit message #9: chore: add openssf scorecard workflow (#359) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> # This is the commit message #10: build(deps): bump compliance-trestle from 3.4.0 to 3.5.0 (#380) Bumps [compliance-trestle](https://github.com/oscal-compass/compliance-trestle) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/oscal-compass/compliance-trestle/releases) - [Changelog](https://github.com/oscal-compass/compliance-trestle/blob/develop/CHANGELOG.md) - [Commits](oscal-compass/compliance-trestle@v3.4.0...v3.5.0) --- updated-dependencies: - dependency-name: compliance-trestle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # This is the commit message #11: docs: adr-001 cli implementation (#347) * docs: adding draft of CLI decision record * docs: adding details around config file * docs: refactor wording for clarity * docs: update config example * expand content for default behaviors around oscal-model # This is the commit message #12: feat: 295 monorepo directory structure design proposal (#389) * initial directory structure organization * feat: initial work on config and common options * chore: add openssf scorecard workflow (#359) Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> * build(deps): bump compliance-trestle from 3.4.0 to 3.5.0 (#380) Bumps [compliance-trestle](https://github.com/oscal-compass/compliance-trestle) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/oscal-compass/compliance-trestle/releases) - [Changelog](https://github.com/oscal-compass/compliance-trestle/blob/develop/CHANGELOG.md) - [Commits](oscal-compass/compliance-trestle@v3.4.0...v3.5.0) --- updated-dependencies: - dependency-name: compliance-trestle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: adds logic to load yaml config into click context to set defautl values. improves config error handling. * feat: adds debug logging statements * feat: add markdown directory creation and call to compliance trestle init * feat: simplify directory creation and better error handling for invalid configs * feat: initial work on autosync * Initial create command for click cli * Initial create command for click cli * adding unit test for config module * adding unit test for config module * Update autosync command * Update autosync command * feat: add ssp index option * feat: add ssp index option * add unit tests for init command * add unit tests for init command * feat: root call create and logging replacement * feat: root call create and logging replacement * feat: add upstream commands, fix common options decorators, expand config * feat: add upstream commands, fix common options decorators, expand config * Update autosync options and add tests * Update autosync options and add tests * docs: adr-001 cli implementation (#347) * docs: adding draft of CLI decision record * docs: adding details around config file * docs: refactor wording for clarity * docs: update config example * expand content for default behaviors around oscal-model * feat: add logic to make_config for nested upstream model and update related tests * feat: add logic to make_config for nested upstream model and update related tests * feat: create command logic for compdef and ssp * feat: create command logic for compdef and ssp * feat: create command updates to prompts and logger messages * feat: create command updates to prompts and logger messages * feat: add default git info to init prompts and config * feat: add default git info to init prompts and config * fix hidden keep file creation * fix hidden keep file creation * Add rule-transform command and unit test * Add rule-transform command and unit test * feat: create command logic and adding unit tests * feat: create command logic and adding unit tests * Fix AttributeError, some misc updates AttributeError: 'NoneType' object has no attribute 'encode' * Fix AttributeError, some misc updates AttributeError: 'NoneType' object has no attribute 'encode' * feat: unit tests added for create command * feat: unit tests added for create command * refactor sync upstreams and autosync to match existing entrypoint syntax * refactor sync upstreams and autosync to match existing entrypoint syntax * Fix AttributeError, some misc updates AttributeError: 'NoneType' object has no attribute 'encode' * Fix AttributeError, some misc updates AttributeError: 'NoneType' object has no attribute 'encode' * feat: unit tests added for create command * feat: unit tests added for create command * fix: docstrings added for create command unit tests * fix: docstrings added for create command unit tests * add file pattern filter * add file pattern filter * fix: updated headers with license and copyright * fix: updated headers with license and copyright * fix: updated logger statements * fix: updated logger statements * fix: logger statements shortened * fix: logger statements shortened * fix: yaml default deletion * fix: yaml default deletion * docs: updates to reference the CLI commands in the README.md * docs: updates to reference the CLI commands in the README.md * feat: update for required ssp name * feat: update for required ssp name * Update trestlebot/cli/commands/init.py Co-authored-by: Jennifer Power <barnabei.jennifer@gmail.com> * Update trestlebot/cli/commands/init.py Co-authored-by: Jennifer Power <barnabei.jennifer@gmail.com> * Update trestlebot/cli/commands/init.py Co-authored-by: Jennifer Power <barnabei.jennifer@gmail.com> * Update trestlebot/cli/commands/init.py Co-authored-by: Jennifer Power <barnabei.jennifer@gmail.com> * fix typo in error msg * fix typo in error msg * fix help text for sync upstreams * fix help text for sync upstreams * fix: update for help text and testing location errors * fix: update for help text and testing location errors * fix: update for clarity on profile name for trestle workspace * fix: update for clarity on profile name for trestle workspace * Fix AssertionError, add missing register * Fix AssertionError, add missing register * fix: profile name prompting update * fix: profile name prompting update * feat: updating compdef list to required * feat: updating compdef list to required * docs: change of verbiage for readability * docs: change of verbiage for readability * docs: change to indicate trestle-bot as a cli tool * docs: change to indicate trestle-bot as a cli tool * feat: change to help description of create command * feat: change to help description of create command * docs: added high level folder structure for cli * docs: added high level folder structure for cli * fix: default value returned if no key in dictionary * fix: default value returned if no key in dictionary * feat: align skip-item option to skip-items * feat: align skip-item option to skip-items * fix: add missing git options in create command * fix: add missing git options in create command * fix: refactor testt and remove prompts * fix: refactor testt and remove prompts * fix: formatting issues and typos * fix: formatting issues and typos * chore: update poetry lock with latest dependencies Signed-off-by: George Vauter <gvauter@redhat.com> * chore: update poetry lock with latest dependencies Signed-off-by: George Vauter <gvauter@redhat.com> * fix: do not overwrite config path if set Signed-off-by: George Vauter <gvauter@redhat.com> * fix: do not overwrite config path if set Signed-off-by: George Vauter <gvauter@redhat.com> * fix: do not overwrite config path if set Signed-off-by: George Vauter <gvauter@redhat.com> * fix: do not overwrite config path if set Signed-off-by: George Vauter <gvauter@redhat.com> --------- Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: George Vauter <gvauter@redhat.com> Co-authored-by: Hannah Braswell <hbraswel@redhat.com> Co-authored-by: Jennifer Power <barnabei.jennifer@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Qingmin Duanmu <qduanmu@redhat.com> # This is the commit message #13: feat: initialize command for cac to oscal transformation # This is the commit message #14: chore: update pyproject.toml entrypoints to cli root command # This is the commit message #15: chore: update actions with new cli design # This is the commit message #16: docs: update CONTRIBUTING.md chore: update actions for debug and config options chore: rename rule-transform to rules-transform fix: update e2e test to use new commands fix: update create command for e2e testing Changes made to use compdef_name reference instead of profile_name for model filter fix: a typo in autosync command fix: sys.exit with errorcode when exceptions fix: fix a typo in cli root feat: populate cac content product name as component title Signed-off-by: Sophia Wang <huiwang@redhat.com> Add unitest for populate cac product nameto component title Signed-off-by: Sophia Wang <huiwang@redhat.com> Move the ssg connections from utils to cac transformer Signed-off-by: Sophia Wang <huiwang@redhat.com> Add function to only update not recreate component definition if it exists Signed-off-by: Sophia Wang <huiwang@redhat.com> Update the component description as the product full name Signed-off-by: Sophia Wang <huiwang@redhat.com> add the sync cac content task to push local change to remote Signed-off-by: Sophia Wang <huiwang@redhat.com> chore: allow lower case in PR subject (#406) Signed-off-by: George Vauter <gvauter@redhat.com> feat: add cac content rules transformation feat: CPLYTM-421 create validation component from rules Signed-off-by: Sophia Wang <huiwang@redhat.com> chore: add notice regarding repo org move (#413) Signed-off-by: George Vauter <gvauter@redhat.com> chore: update SyncCacContentTask feat: add unit test for validation component Signed-off-by: Sophia Wang <huiwang@redhat.com> :arrow_up: bump actions/download-artifact from 4.1.7 to 4.1.8 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.7 to 4.1.8. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@65a9edc...fa0a91b) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> build(deps): bump actions/upload-artifact from 4.3.4 to 4.6.0 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.6.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@0b2256b...65c4c4a) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> feat: sync cac content profile task and subcommand Add create_or_update to AuthoredProfile Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> test: adds tests and updates to sync_cac_profile_task Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> feat: sync cac content profile task and subcommand fix: updating the cac_content_root type to pass a string fix: fixes linting errors for sync_cac_content_profile task Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> feat: sync cac content profile task and subcommand feat: sync cac content profile task and subcommand feat: testing repo passed before content dir feat: testing repo passed before content dir fix: unit tests in pycharm PyCharm sets the CWD of unit tests to the tests directory by default, but the unit tests assume a CWD of the repo root. This updates the unit tests not to rely on the assumption of CWD Signed-off-by: d10n <d10n@redhat.com> feat: testing with catalog path extension feat: testing for metadata checks feat: testing for oscal profile imports fix: testing oscal profile populated in correct path fix: testing oscal profile populated in correct path fix: testing oscal profile populated in correct path fix: testing oscal profile populated in correct path fix: testing oscal profile populated in correct path fix: testing oscal profile populated in correct path fix: pinpointing existing error 2 fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: pinpointing error by not including a default for filter_by_level fix: adding command to root fix: adding modelutils handler for getting the correct catalog path fix: adding modelutils handler for getting the correct catalog path fix: taking catalog kwargs as part of path for profile data fix: taking catalog kwargs as part of path for profile data fix: taking catalog kwargs as part of path for profile data fix: taking catalog kwargs as part of path for profile data feat: updates for unit testing for sync_cac_content_profile command feat: add parameter transformation feat: update poetry.lock and add jinja macros fix: improve the validation components with parameters Signed-off-by: Sophia Wang <huiwang@redhat.com> fix: fix test failure in validation component feat: update rule description value with rule title chore: create a minimalist macro file for unit tests This file contains only the necessary macros used by rules in the content_dir directory. Signed-off-by: Marcus Burghardt <maburgha@redhat.com> chore: remove macros not relevant for current tests This keeps the test content simpler and smaller. Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
1 parent 469fbe8 commit 6e3f39f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5033
-771
lines changed

.github/workflows/codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: make test-code-cov
2626

2727
- name: Upload artifact
28-
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # pin@v4
28+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # pin@v4
2929
with:
3030
name: coverage
3131
path: coverage.xml
@@ -39,7 +39,7 @@ jobs:
3939
with:
4040
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
4141
- name: Get coverage
42-
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
42+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # pin@v4
4343
with:
4444
name: coverage
4545
- name: SonarCloud Scan

.github/workflows/scorecard.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Scorecard analysis workflow
2+
on:
3+
push:
4+
# Only the default branch is supported.
5+
branches:
6+
- main
7+
schedule:
8+
# Weekly on Saturdays.
9+
- cron: '30 1 * * 6'
10+
11+
permissions: read-all
12+
13+
jobs:
14+
analysis:
15+
if: github.repository == 'RedHatProductSecurity/trestle-bot'
16+
name: Scorecard analysis
17+
runs-on: ubuntu-latest
18+
permissions:
19+
# Needed for Code scanning upload
20+
security-events: write
21+
# Needed for GitHub OIDC token if publish_results is true
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v4
27+
with:
28+
persist-credentials: false
29+
30+
- name: Run analysis
31+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
32+
with:
33+
results_file: results.sarif
34+
results_format: sarif
35+
publish_results: true
36+
37+
- name: Upload artifact
38+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # pin@v4
39+
with:
40+
name: SARIF file
41+
path: results.sarif
42+
retention-days: 5
43+
44+
# Upload the results to GitHub's code scanning dashboard (optional).
45+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
46+
- name: Upload to code-scanning
47+
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
48+
with:
49+
sarif_file: results.sarif

CONTRIBUTING.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Before you start contributing, please take a moment to read through the guide be
1818
- [Documentation](#documentation)
1919
- [Architecture Decisions](#architecture-decisions)
2020
- [Update the `actions` files](#update-the-actions-files)
21+
- [Authoring CI Workflows](#authoring-ci-workflows)
2122
- [License Text in Files](#license-text-in-files)
2223
- [Tools](#tools)
2324
- [Format and Styling](#format-and-styling)
@@ -72,7 +73,9 @@ For workflow diagrams, see the [diagrams](./docs/workflows/) under the `docs` fo
7273
#### Code structure
7374

7475
- `actions` - Provides specific logic for `trestle-bot` tasks that are packaged as Actions. See [README.md](./actions/README.md) for more information.
75-
- `entrypoints` - Provides top level logic for specific user-facing tasks. These tasks are not necessarily related in any way so they are not organized into a hierarchical command structure, but they do inherit logic and flags from a base class.
76+
- `cli` - Provides top level logic for specific user-facing tasks. These tasks are not necessarily related so they are not organized into a hierarchical command structure, but they do share some common modules.
77+
- `cli/commands` - Provides top level logic for commands and their associated subcommands. The commands are accessed by the single entrypoint `root.py`.
78+
- `cli/options` - Provides command line options and arguments that are frequently used within `cli/commands`.
7679
- `provider.py, github.py, and gitlab.py` - Git provider abstract class and concrete implementations for interacting with the API.
7780
- `tasks` - Pre-tasks can be configured before the main git logic is run. Any task that does workspace management should go here.
7881
- `tasks/authored` - The `authored` package contains logic for managing authoring tasks for single instances of a top-level OSCAL model. These encapsulate logic from the `compliance-trestle` library and allows loose coupling between `tasks` and `authored` types.
@@ -97,6 +100,17 @@ Each `README.md` under the `actions` directory have an Actions Inputs and Action
97100
make update-action-readmes
98101
```
99102

103+
#### Authoring CI Workflows
104+
105+
The CI workflows for trestle-bot leverage third party actions pinned to a hash value which is updated by `dependabot.yml`. The purpose of pinning actions to a full length commit SHA is to ensure that the action's code and behavior remain consistent. Actions that are pinned to full length commit SHAs act as immutable releases which allow for distinction between versions and an accurate history log. When selecting a commit SHA to include, the SHA value that is associated with the version of the action should be chosen from the associated action's repository. Dependabot checks for the action's reference against the latest version ensuring a secure and consistent approach to managing dependencies and version updating.
106+
107+
To generate a pin for a third party action, there should be a full length commit SHA associated with the version of the action being referenced. The reference used is the full length SHA, tag, or branch that dependabot will use when updating dependencies and bumping versions.
108+
109+
- The syntax for a specified action is: `OWNER/REPOSITORY@TAG-OR-SHA`.
110+
- The syntax for a specified reusable workflow is: `OWNER/REPOSITORY/PATH/FILENAME@TAG-OR-SHA`.
111+
112+
This approach is used for authoring CI workflows that utilize versioned actions to produce frequent updates from dependabot for python and GitHub Actions.
113+
100114
### License Text in Files
101115

102116
Please use the SPDX license identifier in all source files.
@@ -146,11 +160,11 @@ make test-e2e
146160
#### Run with poetry
147161
```
148162
make develop
149-
poetry run trestlebot-autosync
150-
poetry run trestlebot-rules-transform
151-
poetry run trestlebot-create-cd
152-
poetry run trestlebot-sync-upstreams
153-
poetry run trestlebot-create-ssp
163+
poetry run trestlebot autosync
164+
poetry run trestlebot rules-transform
165+
poetry run trestlebot create compdef
166+
poetry run trestlebot sync-upstreams
167+
poetry run trestlebot create ssp
154168
```
155169

156170
#### Local testing
@@ -178,15 +192,15 @@ INPUT_SKIP_ITEMS=
178192
INPUT_DRY_RUN=true
179193
INPUT_SKIP_ASSEMBLE=false
180194
INPUT_SKIP_REGENERATE=false
181-
INPUT_REPOSITORY=.
195+
INPUT_REPO_PATH=.
182196
INPUT_BRANCH=test
183-
INPUT_MARKDOWN_PATH=markdown/profiles
197+
INPUT_MARKDOWN_DIR=markdown/profiles
184198
INPUT_OSCAL_MODEL=profile
185-
INPUT_SSP_INDEX_PATH=
199+
INPUT_SSP_INDEX_FILE=
186200
INPUT_COMMIT_MESSAGE=
187201
INPUT_COMMIT_USER_NAME=testuser
188202
INPUT_COMMIT_USER_EMAIL=test@example.com
189-
INPUT_FILE_PATTERN=*.md,*.json
203+
INPUT_FILE_PATTERNS=*.md,*.json
190204
INPUT_COMMIT_AUTHOR_NAME=
191205
INPUT_COMMIT_AUTHOR_EMAIL=
192206
INPUT_TARGET_BRANCH=
@@ -216,4 +230,4 @@ Once work on a release has been completed:
216230
- Initial releases will have a `major` tag (if stable), `major`.`minor`, and the full version.
217231
- The latest release will be rebuilt every thirty days to pull in base image updates. The same tags will
218232
be published with the addition of `full-version`.`date` tag.
219-
- Images can be built adhoc for testing purposes with the `workflow_dispatch` trigger.
233+
- Images can be built adhoc for testing purposes with the `workflow_dispatch` trigger.

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,35 @@
66
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rh-psce_trestle-bot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rh-psce_trestle-bot)
77

88

9+
** **Note: Trestle-bot has moved from [RedHatProductSecurity](https://github.com/RedHatProductSecurity/) to the [Complytime](https://github.com/complytime/) GitHub organization.** **
910

10-
trestle-bot assists users in leveraging [Compliance-Trestle](https://github.com/oscal-compass/compliance-trestle) in CI/CD workflows for [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.
11+
trestle-bot is a CLI tool that assists users in leveraging [Compliance-Trestle](https://github.com/oscal-compass/compliance-trestle) in CI/CD workflows for [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.
1112

1213
> WARNING: This project is currently under initial development. APIs may be changed incompatibly from one commit to another.
1314
1415
## Getting Started
1516

1617
### Available Commands
1718

18-
The `autosync` command will sync trestle-generated Markdown files to OSCAL JSON files in a trestle workspace. All content under the provided markdown directory when the action is run will be transformed. This action supports all top-level models [supported by compliance-trestle for authoring](https://oscal-compass.github.io/compliance-trestle/tutorials/ssp_profile_catalog_authoring/ssp_profile_catalog_authoring/).
19+
The `autosync` command will sync trestle-generated Markdown files to OSCAL JSON files in a trestle workspace. All content under the provided markdown directory will be transformed when the action is run. This action supports all top-level models [supported by compliance-trestle for authoring](https://oscal-compass.github.io/compliance-trestle/tutorials/ssp_profile_catalog_authoring/ssp_profile_catalog_authoring/).
1920

2021
The `rules-transform` command can be used when managing [OSCAL Component Definitions](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will transform rules defined in the rules YAML view to an OSCAL Component Definition JSON file.
2122

22-
The `create-cd` command can be used to create a new [OSCAL Component Definition](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will create a new Component Definition JSON file and corresponding directories that contain rules YAML files and trestle-generated Markdown files. This action prepares the workspace for use with the `rules-transform` and `autosync` actions.
23+
The `create compdef` command can be used to create a new [OSCAL Component Definition](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will create a new Component Definition JSON file and corresponding directories that contain rules YAML files and trestle-generated Markdown files. This action prepares the workspace for use with the `rules-transform` and `autosync` actions.
2324

24-
The `sync-upstreams` command can be used to sync and validate upstream OSCAL content stored in a git repository to a local trestle workspace. Which content is synced is determined by the `include_model_names` and `exclude_model_names` inputs.
25+
The `sync-upstreams` command can be used to sync and validate upstream OSCAL content stored in a git repository to a local trestle workspace. The inputs `include_models` and `exclude_models` determine which content is synced to the trestle workspace.
2526

26-
The `create-ssp` command can be used to create a new [OSCAL System Security Plans](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/system-security-plan/json-outline/) (SSP) in a trestle workspace. The action will create a new SSP JSON file and corresponding directories that contain trestle-generated Markdown files. This action prepares the workspace for use with the `autosync` action by creating or updating the `ssp-index.json` file. The `ssp-index.json` file is used to track the relationships between the SSP and the other OSCAL content in the workspace for the `autosync` action.
27+
The `create ssp` command can be used to create a new [OSCAL System Security Plans](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/system-security-plan/json-outline/) (SSP) in a trestle workspace. The action will create a new SSP JSON file and corresponding directories that contain trestle-generated Markdown files. This action prepares the workspace for use with the `autosync` action by creating or updating the `ssp-index.json` file. The `ssp-index.json` file is used to track the relationships between the SSP and the other OSCAL content in the workspace for the `autosync` action.
2728

2829
Below is a table of the available commands and their current availability as a GitHub Action:
2930

30-
| Command | Available as a GitHub Action |
31-
|--------------------|------------------------------|
32-
| `autosync` | &#10003; |
33-
| `rules-transform` | &#10003; |
34-
| `create-cd` | &#10003; |
35-
| `sync-upstreams` | &#10003; |
36-
| `create-ssp` | |
31+
| Command | Available as a GitHub Action |
32+
|-------------------|------------------------------|
33+
| `autosync` | &#10003; |
34+
| `rules-transform` | &#10003; |
35+
| `create compdef` | &#10003; |
36+
| `sync-upstreams` | &#10003; |
37+
| `create ssp` | |
3738

3839
For detailed documentation on how to use each action, see the README.md in each folder under [actions](./actions/).
3940

@@ -47,7 +48,7 @@ provider information is supported for GitHub Actions (GitHub) and GitLab CI (Git
4748

4849
### Run as a Container
4950

50-
> Note: When running the commands in a container, all are prefixed with `trestlebot` (e.g. `trestlebot-autosync`). The default entrypoint for the container is the autosync command.
51+
> Note: When running the commands in a container, all are prefixed with `trestlebot` (e.g. `trestlebot autosync`). The default entrypoint for the container is the autosync command.
5152
5253
Build and run the container locally:
5354

@@ -72,4 +73,4 @@ This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LIC
7273

7374
## Troubleshooting
7475

75-
See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) for troubleshooting tips.
76+
See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) for troubleshooting tips.

TEMPLATES/github/trestlebot-rules-transform.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,24 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
jobs:
20+
check_rules:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
rules_changed: ${{ steps.changes.outputs.rules }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dorny/paths-filter@v3
27+
id: changes
28+
with:
29+
filters: |
30+
rules:
31+
- 'rules/**'
2032
rules-transform-and-autosync:
2133
name: Rules Transform and AutoSync
2234
runs-on: ubuntu-latest
2335
permissions:
2436
contents: write
37+
needs: check_rules
2538
steps:
2639
- name: Checkout repository
2740
uses: actions/checkout@v4
@@ -31,16 +44,9 @@ jobs:
3144
with:
3245
markdown_path: "markdown/component-definitions"
3346
oscal_model: "compdef"
34-
file_pattern: "*.json,markdown/*"
35-
- name: Check if rules changed
36-
id: changes
37-
uses: dorny/paths-filter@v3
38-
with:
39-
filters: |
40-
rules:
41-
- 'rules/**'
47+
commit_message: "Autosync component definition content [skip ci]"
4248
- name: Rules Transform
43-
if: steps.changes.outputs.rules == 'true'
49+
if: needs.check_rules.outputs.rules_changed == 'true'
4450
uses: RedHatProductSecurity/trestle-bot/actions/rules-transform@main
4551
with:
4652
markdown_path: "markdown/component-definitions"

actions/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ This document provides instructions and examples for creating and using GitHub A
77
## Directory Structure
88

99
- Actions related to trestle-bot are located in the `actions` directory.
10-
- Actions should correlate an entrypoint under the `trestlebot/entrypoints` directory.
10+
- Actions should correlate a command under the `trestlebot/cli/commands` directory.
1111

1212
## Adding a New Action
1313

1414
Contributors should scope trestle-bot actions to workspace management and checks. To add a new action:
1515

16-
> Prerequisite: An entrypoint was created under the `trestlebot/entrypoints` directory and added to the `pyproject.toml` under `[tool.poetry.scripts]`
16+
> Prerequisite: An entrypoint was created under the `trestlebot/cli` directory and added to the `pyproject.toml` under `[tool.poetry.scripts]`
1717
1818
1. Create a new directory in the `actions` directory.
1919
2. In the new directory, create an `action.yml` file that references the Dockerfile in the root of the repository.
@@ -48,7 +48,7 @@ jobs:
4848
- uses: actions/checkout@v4
4949
- uses: RedHatProductSecurity/trestle-bot/actions/create-cd@main
5050
with:
51-
markdown_path: "markdown/components"
51+
markdown_dir: "markdown/components"
5252
profile_name: "my-profile"
5353
component_definition_name: "my-component-definition"
5454
component_title: "my-component"
@@ -96,7 +96,7 @@ jobs:
9696
id: autosync
9797
uses: RedHatProductSecurity/trestle-bot/actions/autosync@main
9898
with:
99-
markdown_path: "md_comp"
99+
markdown_dir: "md_comp"
100100
oscal_model: "compdef"
101101
commit_message: "Autosync component definition content [skip ci]"
102102
# Rule transformation is not idempotent, so you may only want to run this
@@ -115,7 +115,7 @@ jobs:
115115
id: transform
116116
uses: RedHatProductSecurity/trestle-bot/actions/rules-transform@main
117117
with:
118-
markdown_path: "md_comp"
118+
markdown_dir: "md_comp"
119119
commit_message: "Auto-transform rules [skip ci]"
120120
```
121121

@@ -148,7 +148,7 @@ jobs:
148148
id: autosync
149149
uses: RedHatProductSecurity/trestle-bot/actions/autosync@main
150150
with:
151-
markdown_path: "md_comp"
151+
markdown_dir: "md_comp"
152152
oscal_model: "compdef"
153153
dry_run: true
154154
- uses: dorny/paths-filter@v3
@@ -162,7 +162,7 @@ jobs:
162162
id: transform
163163
uses: RedHatProductSecurity/trestle-bot/actions/rules-transform@main
164164
with:
165-
markdown_path: "md_comp"
165+
markdown_dir: "md_comp"
166166
dry_run: true
167167
```
168168

@@ -210,7 +210,7 @@ jobs:
210210
if: steps.trestlebot.outputs.changes == 'true'
211211
uses: RedHatProductSecurity/trestle-bot/actions/autosync@main
212212
with:
213-
markdown_path: "markdown/components"
213+
markdown_dir: "markdown/components"
214214
oscal_model: "compdef"
215215
branch: "sync-upstream-${{ github.run_id }}"
216216
skip_assemble: true
@@ -244,7 +244,7 @@ jobs:
244244
- name: Autosync
245245
uses: RedHatProductSecurity/trestle-bot/actions/autosync@main
246246
with:
247-
markdown_path: "md_comp"
247+
markdown_dir: "md_comp"
248248
oscal_model: "compdef"
249249
commit_message: "Update content for release [skip ci]"
250250
version: ${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)