Skip to content

Commit

Permalink
Merge branch 'main' into add_drilldown_support
Browse files Browse the repository at this point in the history
  • Loading branch information
pyth0n1c authored Oct 15, 2024
2 parents 80aa067 + c558216 commit a4f4222
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from shutil import copyfile
from typing import Union, Optional

from pydantic import BaseModel, PrivateAttr, Field, dataclasses
from pydantic import ConfigDict, BaseModel, PrivateAttr, Field, dataclasses
import requests # type: ignore
import splunklib.client as client # type: ignore
from splunklib.binding import HTTPError # type: ignore
Expand Down Expand Up @@ -48,9 +48,9 @@ class SetupTestGroupResults(BaseModel):
success: bool = True
duration: float = 0
start_time: float

class Config:
arbitrary_types_allowed = True
model_config = ConfigDict(
arbitrary_types_allowed=True
)


class CleanupTestGroupResults(BaseModel):
Expand Down Expand Up @@ -91,9 +91,9 @@ class DetectionTestingInfrastructure(BaseModel, abc.ABC):
_conn: client.Service = PrivateAttr()
pbar: tqdm.tqdm = None
start_time: Optional[float] = None

class Config:
arbitrary_types_allowed = True
model_config = ConfigDict(
arbitrary_types_allowed=True
)

def __init__(self, **data):
super().__init__(**data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from bottle import template, Bottle, ServerAdapter
from contentctl.actions.detection_testing.views.DetectionTestingView import (
DetectionTestingView,
)
from threading import Thread

from bottle import template, Bottle, ServerAdapter
from wsgiref.simple_server import make_server, WSGIRequestHandler
import jinja2
import webbrowser
from threading import Thread
from pydantic import ConfigDict

from contentctl.actions.detection_testing.views.DetectionTestingView import (
DetectionTestingView,
)

DEFAULT_WEB_UI_PORT = 7999

Expand Down Expand Up @@ -100,9 +102,9 @@ def log_exception(*args, **kwargs):
class DetectionTestingViewWeb(DetectionTestingView):
bottleApp: Bottle = Bottle()
server: SimpleWebServer = SimpleWebServer(host="0.0.0.0", port=DEFAULT_WEB_UI_PORT)

class Config:
arbitrary_types_allowed = True
model_config = ConfigDict(
arbitrary_types_allowed=True
)

def setup(self):
self.bottleApp.route("/", callback=self.showStatus)
Expand Down
13 changes: 6 additions & 7 deletions contentctl/enrichments/cve_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shelve
import time
from typing import Annotated, Any, Union, TYPE_CHECKING
from pydantic import BaseModel,Field, computed_field
from pydantic import ConfigDict, BaseModel,Field, computed_field
from decimal import Decimal
from requests.exceptions import ReadTimeout
from contentctl.objects.annotated_types import CVE_TYPE
Expand All @@ -32,13 +32,12 @@ def url(self)->str:
class CveEnrichment(BaseModel):
use_enrichment: bool = True
cve_api_obj: Union[CVESearch,None] = None


class Config:
# Arbitrary_types are allowed to let us use the CVESearch Object
arbitrary_types_allowed = True
frozen = True
# Arbitrary_types are allowed to let us use the CVESearch Object
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True
)

@staticmethod
def getCveEnrichment(config:validate, timeout_seconds:int=10, force_disable_enrichment:bool=True)->CveEnrichment:
Expand Down
14 changes: 7 additions & 7 deletions contentctl/objects/base_test_result.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Union, Any
from enum import Enum

from pydantic import BaseModel
from splunklib.data import Record
from pydantic import ConfigDict, BaseModel
from splunklib.data import Record # type: ignore

from contentctl.helper.utils import Utils

Expand Down Expand Up @@ -53,11 +53,11 @@ class BaseTestResult(BaseModel):
# The Splunk endpoint URL
sid_link: Union[None, str] = None

class Config:
validate_assignment = True

# Needed to allow for embedding of Exceptions in the model
arbitrary_types_allowed = True
# Needed to allow for embedding of Exceptions in the model
model_config = ConfigDict(
validate_assignment=True,
arbitrary_types_allowed=True
)

@property
def passed(self) -> bool:
Expand Down
Loading

0 comments on commit a4f4222

Please sign in to comment.