-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created python script to dynamically compute devel enviroment file * Added SHVVL * Added conda to attacker and hp * Added dev env for manager * Added jake * Fixed honeypot, large change. Also altered linting behaviour. * Got manager running * Re-enabled yamllint, and fixed entry for honeypot in compose * Made CI mamba * Modified workflow * Fixed makefile errors * Saved space on dev env * Security + cleanup * Modified security policy * Made safety not mad * CI opti * CI Correction * CI Correction pt 2 * CI + Gitignore fixes * Make linter happy * More fixes * Loosened yamllint rules * makefile * Added additional opti * workflow
- Loading branch information
1 parent
e202eb6
commit f814179
Showing
26 changed files
with
492 additions
and
101 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -18,14 +18,29 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
auto-update-conda: true | ||
python-version: ${{ matrix.python-version }} | ||
- uses: mamba-org/[email protected] | ||
|
||
- name: Set up environment | ||
- name: Fetch dependancies | ||
run: sudo apt-get install libpcap-dev | ||
|
||
- name: Set up and scan environment | ||
run: echo $ENV_FILE | base64 --decode > manager/.env && make init | ||
|
||
- name: CI-Specific optimization (Disable GPU) | ||
run: sed 's/ - torch==/ - --extra-index-url https:\/\/download.pytorch.org\/whl\/cpu\n&/' -i manager/environment-manager.yml | ||
|
||
- name: CI-Specific optimization (Remove Development Envs) | ||
run: | | ||
micromamba env remove -n attacker-dev | ||
micromamba env remove -n honeypot-dev | ||
micromamba env remove -n manager-dev | ||
- name: CI-Specific optimization (Purge Cache) | ||
run: pip cache purge && micromamba clean -a | ||
|
||
- name: CI-Specific optimization (Lower SIEM message journal max size) | ||
run: echo "RUN sed -i 's/#message_journal_max_size = 5gb/message_journal_max_size = 500mb/' /usr/share/graylog/data/config/graylog.conf" >> siem/Dockerfile | ||
|
||
- name: Build Containers | ||
run: make build | ||
|
||
|
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,8 @@ | ||
security: | ||
continue-on-vulnerability-error: False | ||
ignore-cvss-severity-below: 0 | ||
ignore-cvss-unknown-severity: False | ||
ignore-vulnerabilities: | ||
65052: | ||
reason: Disputed + not impacted accd to vendor | ||
expires: '2024-06-17' |
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
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,11 @@ | ||
--- | ||
name: base | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.11.9 | ||
- pip=24.* | ||
- PyJWT=2.8.0 | ||
- python-dotenv=1.0.1 | ||
- requests=2.31.0 | ||
- selenium=4.18.1 |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import yaml | ||
from packaging.version import Version | ||
|
||
def pkg_list_to_dict(depsList: list[str], isPip: bool) -> dict: | ||
depDict = {} | ||
for package in depsList: | ||
if not isPip and type(package) is not str: | ||
continue | ||
pkgName, pkgVer = package.split("==" if isPip else "=") | ||
depDict[pkgName] = pkgVer | ||
return depDict | ||
|
||
def dev_corrections(pipDict: dict) -> None: | ||
if "psycopg2" in pipDict.keys(): | ||
ver = pipDict["psycopg2"] | ||
del pipDict["psycopg2"] | ||
pipDict["psycopg2-binary"] = ver | ||
|
||
|
||
|
||
|
||
def main() -> None: | ||
for reqLoc in ["attacker", "honeypot", "manager"]: | ||
with open(reqLoc + "/environment-"+ reqLoc + ".yml", "r") as baseEnvFp: | ||
handle : dict = yaml.load(baseEnvFp, yaml.Loader) | ||
handle["name"] = reqLoc + "-dev" | ||
|
||
pipDeps = {} | ||
print(type(handle["dependencies"][-1])) | ||
if type(handle["dependencies"][-1]) is dict and "pip" in handle["dependencies"][-1].keys(): | ||
pipDeps :dict = pkg_list_to_dict(handle["dependencies"][-1]["pip"], True) | ||
dev_corrections(pipDeps) | ||
|
||
deps :dict = pkg_list_to_dict(handle["dependencies"], False) | ||
print(deps) | ||
dev_corrections(deps) | ||
handle["dependencies"]=[dep + "=" + deps[dep] for dep in deps.keys()] | ||
|
||
if len(pipDeps) != 0: | ||
parsedPip = {"pip":[dep + "==" + pipDeps[dep] for dep in pipDeps.keys()]} | ||
if "torch" in pipDeps.keys(): | ||
torchloc = parsedPip["pip"].index("torch=="+ pipDeps["torch"]) | ||
parsedPip["pip"].insert(torchloc, "--extra-index-url https://download.pytorch.org/whl/cpu") | ||
|
||
handle["dependencies"].append(parsedPip) | ||
|
||
|
||
with open(reqLoc+"/environment.yml", "w") as computedEnvFp: | ||
computedEnvFp.write("---\n") | ||
yaml.dump(handle, computedEnvFp) | ||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,55 @@ | ||
#In a seperate file for now | ||
|
||
import yaml | ||
|
||
def quick_figure(package: str, ver): | ||
return package if ver == -1 else package + "==" + ver | ||
|
||
def dev_alt(altList:list, pkg: str) -> list: | ||
pkgName, pkgVer = pkg.split("==") if len(pkg.split("==")) == 2 else [pkg, -1] | ||
if pkgName == "psycopg2": | ||
altList.append(quick_figure("psycopg2-binary",pkgVer)) | ||
elif pkgName == "torch": | ||
altList.append("-i https://download.pytorch.org/whl/cpu") | ||
altList.append(pkg) | ||
|
||
|
||
def transcribe(envLoc: str, envName: str): | ||
with open(envLoc + "environment-"+ envName + ".yml", "r") as baseEnvFp: | ||
normalDeps=[] | ||
devDeps=[] | ||
|
||
condaDeps : list = yaml.load(baseEnvFp, yaml.Loader)["dependencies"] | ||
for dep in condaDeps[:-1]: | ||
dep = dep.replace("=", "==") | ||
|
||
normalDeps.append(dep) | ||
dev_alt(devDeps, dep) | ||
|
||
|
||
if type(condaDeps[-1]) is dict and "pip" in condaDeps[-1].keys(): | ||
for dep in condaDeps[-1]["pip"]: | ||
normalDeps.append(dep) | ||
dev_alt(devDeps, dep) | ||
|
||
#FIXME: Sometimes this doesn't update existing req files | ||
with open(envLoc+"reqs.txt", "w") as computedReqs: | ||
for line in normalDeps: | ||
computedReqs.write(line + "\n") | ||
|
||
print(devDeps) | ||
with open(envLoc+"reqsDev.txt", "w") as computedDevReqs: | ||
for line in devDeps: | ||
computedDevReqs.write(line + "\n") | ||
|
||
def main() -> None: | ||
envList = [[a+"/",a] for a in ["attacker", "honeypot", "manager"]] | ||
envList.append(["","core"]) | ||
|
||
for r in envList: | ||
transcribe(*r) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.