Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d13540f
Add reporting command support back
pyth0n1c Apr 30, 2024
eba7e10
Enrichment is not required for reporting. Remove that requirement.
pyth0n1c Apr 30, 2024
cc1007a
coverage badge being generated incorrectly
pyth0n1c Apr 30, 2024
349d80d
minor template tweaks to improve
pyth0n1c Apr 30, 2024
313ef36
initial support for env parsing
pyth0n1c May 1, 2024
3b819ca
make sure test_Servers workflow works
pyth0n1c May 1, 2024
c43a873
add more verbose exception print
pyth0n1c May 1, 2024
d2cd8b0
version should not be included in the annotations
pyth0n1c May 1, 2024
a244288
during initialize, make sure that app_template
pyth0n1c May 1, 2024
7082e45
bum pyproject version of
pyth0n1c May 1, 2024
8473fb7
use proper paths for docker apps dir.
pyth0n1c May 1, 2024
a1f538b
clean up lots of dead code
pyth0n1c May 1, 2024
4c0cd06
possible release notes progress
pyth0n1c May 2, 2024
0a7cfa6
Improve type annotations on
pyth0n1c May 2, 2024
1a7a1ee
Release notes working. output was diffed
pyth0n1c May 2, 2024
cfd1e51
make contentctl --help work even if it is missing the contentctl.yml
pyth0n1c May 2, 2024
1613903
improve release notes
pyth0n1c May 2, 2024
0c94040
Generate separate BA and App
pyth0n1c May 2, 2024
3770783
Only download/stage files once before
pyth0n1c May 2, 2024
b489b04
print container info
pyth0n1c May 2, 2024
5acb81e
printed out wrong values.
pyth0n1c May 2, 2024
73dff19
slightly improved print for container start
pyth0n1c May 2, 2024
297d2b0
Add support for suppressing tqdm
pyth0n1c May 2, 2024
2b39c32
If tqdm is suppressed but post_test_behavior
pyth0n1c May 2, 2024
89b0d25
Update workflow so that testing has "never_pause" set
pyth0n1c May 2, 2024
f0be80b
adding deprecated notes
patel-bhavin May 2, 2024
a05dc89
Merge pull request #139 from splunk/deprecated_notes
pyth0n1c May 2, 2024
ffe7240
fix small typo in conifg.pu
pyth0n1c May 2, 2024
fe29f44
change suppress-tqdm to
pyth0n1c May 2, 2024
8829168
updat end to end test after renaming
pyth0n1c May 2, 2024
c608dda
Fix bug where -container-settings.num-containers
pyth0n1c May 3, 2024
bb75f72
Add newline during print for better formatting
pyth0n1c May 3, 2024
d24f893
minor changes to printouts.
pyth0n1c May 3, 2024
163dda9
Switch hard requirement for ES
pyth0n1c May 6, 2024
c2008d1
Removed explicit check for
pyth0n1c May 6, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/testEndToEnd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Run contentctl init
run: |
cd my_splunk_content_pack
poetry run contentctl init
poetry run contentctl init

- name: Clone the AtomicRedTeam Repo
run: |
Expand All @@ -73,7 +73,7 @@ jobs:
if: startsWith(matrix.operating_system, 'ubuntu')
run: |
cd my_splunk_content_pack
poetry run contentctl test
poetry run contentctl test --disable-tqdm --post-test-behavior never_pause

- uses: actions/upload-artifact@v4
with:
Expand Down
10 changes: 8 additions & 2 deletions contentctl/actions/detection_testing/DetectionTestingManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,24 @@ def create_DetectionTestingInfrastructureObjects(self):
except Exception as e:
raise Exception(f"Failed to pull docker container image [{self.input_dto.config.container_settings.full_image_path}]: {str(e)}")

already_staged_container_files = False
for infrastructure in self.input_dto.config.test_instances:

if (isinstance(self.input_dto.config, test) and isinstance(infrastructure, Container)):
# Stage the files in the apps dir so that they can be passed directly to
# subsequent containers. Do this here, instead of inside each container, to
# avoid duplicate downloads/moves/copies
if not already_staged_container_files:
self.input_dto.config.getContainerEnvironmentString(stage_file=True)
already_staged_container_files = True

self.detectionTestingInfrastructureObjects.append(
DetectionTestingInfrastructureContainer(
global_config=self.input_dto.config, infrastructure=infrastructure, sync_obj=self.output_dto
)
)

elif isinstance(infrastructure, Infrastructure):

elif (isinstance(self.input_dto.config, test_servers) and isinstance(infrastructure, Infrastructure)):
self.detectionTestingInfrastructureObjects.append(
DetectionTestingInfrastructureServer(
global_config=self.input_dto.config, infrastructure=infrastructure, sync_obj=self.output_dto
Expand Down
4 changes: 2 additions & 2 deletions contentctl/actions/detection_testing/GitService.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from contentctl.objects.lookup import Lookup
from contentctl.objects.detection import Detection
from contentctl.objects.security_content_object import SecurityContentObject
from contentctl.objects.config import test, All, Changes, Selected
from contentctl.objects.config import test_common, All, Changes, Selected

# Logger
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
Expand All @@ -28,7 +28,7 @@

class GitService(BaseModel):
director: DirectorOutputDto
config: test
config: test_common
gitHash: Optional[str] = None

def getHash(self)->str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from urllib3 import disable_warnings
import urllib.parse

from contentctl.objects.config import test, test_servers, test_common, Infrastructure
from contentctl.objects.config import test_common, Infrastructure
from contentctl.objects.enums import PostTestBehavior, AnalyticsType
from contentctl.objects.detection import Detection
from contentctl.objects.base_test import BaseTest
Expand All @@ -32,7 +32,6 @@
from contentctl.objects.unit_test_attack_data import UnitTestAttackData
from contentctl.objects.unit_test_result import UnitTestResult
from contentctl.objects.integration_test_result import IntegrationTestResult
#from contentctl.objects.test_config import TestConfig, Infrastructure
from contentctl.objects.test_group import TestGroup
from contentctl.objects.base_test_result import TestResultStatus
from contentctl.objects.correlation_search import CorrelationSearch, PbarData
Expand Down Expand Up @@ -79,7 +78,7 @@ class DetectionTestingManagerOutputDto():

class DetectionTestingInfrastructure(BaseModel, abc.ABC):
# thread: threading.Thread = threading.Thread()
global_config: Union[test,test_servers]
global_config: test_common
infrastructure: Infrastructure
sync_obj: DetectionTestingManagerOutputDto
hec_token: str = ""
Expand Down Expand Up @@ -396,7 +395,7 @@ def execute(self):
try:
self.test_detection(detection)
except ContainerStoppedException:
self.pbar.write(f"Stopped container [{self.get_name()}]")
self.pbar.write(f"Warning - container was stopped when trying to execute detection [{self.get_name()}]")
self.finish()
return
except Exception as e:
Expand Down Expand Up @@ -1357,7 +1356,7 @@ def status(self):
pass

def finish(self):
self.pbar.bar_format = f"Stopped container [{self.get_name()}]"
self.pbar.bar_format = f"Finished running tests on instance: [{self.get_name()}]"
self.pbar.update()
self.pbar.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
import docker.models.containers
import docker
import docker.types
from contentctl.objects.test_config import (
CONTAINER_APP_DIR,
LOCAL_APP_DIR,
)


class DetectionTestingInfrastructureContainer(DetectionTestingInfrastructure):
Expand Down Expand Up @@ -78,8 +74,8 @@ def make_container(self) -> docker.models.resource.Model:

mounts = [
docker.types.Mount(
source=str(LOCAL_APP_DIR.absolute()),
target=str(CONTAINER_APP_DIR.absolute()),
source=str(self.global_config.getLocalAppDir()),
target=str(self.global_config.getContainerAppDir()),
type="bind",
read_only=True,
)
Expand All @@ -88,7 +84,9 @@ def make_container(self) -> docker.models.resource.Model:
environment = {}
environment["SPLUNK_START_ARGS"] = "--accept-license"
environment["SPLUNK_PASSWORD"] = self.infrastructure.splunk_app_password
environment["SPLUNK_APPS_URL"] = self.global_config.getContainerEnvironmentString(stage_file=True)
# Files have already been staged by the time that we call this. Files must only be staged
# once, not staged by every container
environment["SPLUNK_APPS_URL"] = self.global_config.getContainerEnvironmentString(stage_file=False)
if (
self.global_config.splunk_api_username is not None
and self.global_config.splunk_api_password is not None
Expand Down Expand Up @@ -119,6 +117,18 @@ def emit_docker_run_equivalent():
detach=True,
platform="linux/amd64"
)

if self.global_config.enterpriseSecurityInApps():
#ES sets up https, so make sure it is included in the link
address = f"https://{self.infrastructure.instance_address}:{self.infrastructure.web_ui_port}"
else:
address = f"http://{self.infrastructure.instance_address}:{self.infrastructure.web_ui_port}"
print(f"\nStarted container with the following information:\n"
f"\tname : [{self.get_name()}]\n"
f"\taddress : [{address}]\n"
f"\tusername: [{self.infrastructure.splunk_app_username}]\n"
f"\tpassword: [{self.infrastructure.splunk_app_password}]\n"
)

return container

Expand All @@ -140,6 +150,8 @@ def removeContainer(self, removeVolumes: bool = True, forceRemove: bool = True):
# container was found, so now we try to remove it
# v also removes volumes linked to the container
container.remove(v=removeVolumes, force=forceRemove)
print(f"container [{self.get_name()}] successfully removed")

# remove it even if it is running. remove volumes as well
# No need to print that the container has been removed, it is expected behavior

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from pydantic import BaseModel

from contentctl.objects.test_config import TestConfig
from contentctl.objects.config import test
from contentctl.objects.config import test_common

from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructure import (
DetectionTestingManagerOutputDto,
Expand All @@ -14,7 +13,7 @@


class DetectionTestingView(BaseModel, abc.ABC):
config: test
config: test_common
sync_obj: DetectionTestingManagerOutputDto

interval: float = 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
from pydantic import BaseModel
import abc
from typing import Callable
from contentctl.objects.test_config import TestConfig
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructure import (
DetectionTestingManagerOutputDto,
)

from contentctl.actions.detection_testing.views.DetectionTestingView import (
DetectionTestingView,
)
Expand Down
2 changes: 1 addition & 1 deletion contentctl/actions/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def execute(self, config: test) -> None:
source_directory = pathlib.Path(os.path.dirname(__file__))/templateDir
target_directory = config.path/targetDir
#Throw an exception if the target exists
shutil.copytree(source_directory, targetDir, dirs_exist_ok=False)
shutil.copytree(source_directory, target_directory, dirs_exist_ok=False)

#Create the config file as well
shutil.copyfile(pathlib.Path(os.path.dirname(__file__))/'../templates/README','README')
Expand Down
Loading