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

Fixed validation issues #250

Merged
merged 2 commits into from
May 7, 2024
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
10 changes: 3 additions & 7 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ jobs:
--cov-report term-missing \
--cov-report xml:cov/coverage.xml \
--cov=tenable tests
- name: Test if the library is installable
run: |
pip install .
cd aux_tests && pytest test_installable.py
- name: Save Coverage Report
uses: actions/upload-artifact@v2
with:
Expand All @@ -48,7 +44,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: "3.10"
- name: Setup environment
run: |
python -m pip install -U pip
Expand All @@ -59,12 +55,12 @@ jobs:
flake8-plugin-utils
- name: Run flake8
run: |
flake8 tenable \
flake8 tenb2jira \
--count \
--select=E9,F63,F7,F82 \
--show-source \
--statistics
flake8 tenable \
flake8 tenb2jira \
--count \
--exit-zero \
--max-complexity=12 \
Expand Down
2 changes: 1 addition & 1 deletion tenb2jira/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def validate(configfile: Path):
errors = validator.validate(config)
if errors:
for error in errors:
location = '.'.join(error.get('loc', []))
location = '.'.join([str(e) for e in error.get('loc', [])])
data = tomlkit.dumps(error.get('input'))
console.print(f'{location}: {error.get("msg")}')
console.print(data)
Expand Down
28 changes: 14 additions & 14 deletions tenb2jira/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
from pydantic import BaseModel, Field, ValidationError


class Platform(Enum):
tvm = 'tvm'
tsc = 'tsc'
class Platform(str, Enum):
tvm: str = 'tvm'
tsc: str = 'tsc'


class Severity(Enum):
class Severity(str, Enum):
critical = 'critical'
high = 'high'
medium = 'medium'
low = 'low'


class TaskType(Enum):
task = 'task'
subtask = 'subtask'
class TaskType(str, Enum):
task: str = 'task'
subtask: str = 'subtask'


class State(Enum):
class State(str, Enum):
open = 'open'
reopened = 'reopened'
fixed = 'fixed'
Expand All @@ -31,7 +31,7 @@ class JiraParagraph(BaseModel):
attr: str


class JiraDescription(BaseModel):
class JiraDescription(BaseModel, use_enum_values=True):
tvm: List[JiraParagraph]
tsc: List[JiraParagraph]

Expand All @@ -43,7 +43,7 @@ class SeverityMap(BaseModel):
low: int


class JiraField(BaseModel):
class JiraField(BaseModel, use_enum_values=True):
id: Optional[str] = None
name: str
screen_tab: str
Expand All @@ -57,7 +57,7 @@ class JiraField(BaseModel):
static_value: Optional[str] = None


class JiraTask(BaseModel):
class JiraTask(BaseModel, use_enum_values=True):
id: Optional[int] = None
name: str
type: str
Expand All @@ -77,7 +77,7 @@ class JiraProject(BaseModel):
template_key: str


class Jira(BaseModel):
class Jira(BaseModel, use_enum_values=True):
api_token: str
api_username: str
url: str
Expand All @@ -89,7 +89,7 @@ class Jira(BaseModel):
fields: List[JiraField]


class Tenable(BaseModel):
class Tenable(BaseModel, use_enum_values=True):
platform: Platform
access_key: str
secret_key: str
Expand All @@ -106,7 +106,7 @@ class MappingDatabase(BaseModel):
path: str


class Configuration(BaseModel):
class Configuration(BaseModel, use_enum_values=True):
tenable: Tenable
jira: Jira
mapping_database: MappingDatabase
Expand Down
2 changes: 1 addition & 1 deletion tenb2jira/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '2.0.0'
version = '2.0.1'
Loading