Skip to content

Commit

Permalink
Fixed validation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMcGrath committed May 7, 2024
1 parent 4e9807d commit 7363a97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
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'

0 comments on commit 7363a97

Please sign in to comment.