-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transformer): add basic validation for TrestleRule with pydantic
Signed-off-by: Jennifer Power <[email protected]>
- Loading branch information
Showing
8 changed files
with
88 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
x-trestle-rule-info: | ||
name: example_rule_1 | ||
description: My rule description for example rule 1 | ||
parameter: | ||
name: prm_1 | ||
description: prm_1 description | ||
alternative-values: "invalid" | ||
default-value: true | ||
profile: | ||
description: Simple NIST Profile | ||
href: profiles/simplified_nist_profile/profile.json | ||
include-controls: | ||
- id: ac-2 | ||
x-trestle-component-info: | ||
name: Component 1 | ||
description: Component 1 description | ||
type: service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
|
||
# Copyright 2023 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
"""Base transformer for rules.""" | ||
|
||
from abc import abstractmethod | ||
|
||
from trestle.transforms.transformer_factory import TransformerBase | ||
|
||
from trestlebot.transformers.trestle_rule import TrestleRule | ||
|
||
|
||
class RulesTransformer(TransformerBase): | ||
"""Abstract interface for transformers for rules""" | ||
|
||
@abstractmethod | ||
def transform(self, blob: str) -> TrestleRule: | ||
"""Transform rule data.""" | ||
|
||
|
||
class RulesTransformerException(Exception): | ||
"""An error during transformation of a rule""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters