RC 1.1.1
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
sys.path.append(project_root)
|
||||
|
||||
|
||||
from services.API import AirlockAPIWrapper
|
||||
from services.security import getAPI
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
def main():
|
||||
try:
|
||||
url = "https://172.17.22.240:3129"
|
||||
username = os.getenv("USERNAME")
|
||||
|
||||
if not url:
|
||||
raise ValueError("Missing URL in environment variables.")
|
||||
if not username:
|
||||
raise ValueError("Missing USERNAME in environment variables.")
|
||||
|
||||
logger.debug(f"Retrieved URL: {url}")
|
||||
logger.debug(f"Retrieved Username: {username}")
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
if username:
|
||||
api = AirlockAPIWrapper(
|
||||
base_url= url,
|
||||
api_key = getAPI(username, "AirlockTools"), # pyright: ignore[reportArgumentType]
|
||||
)
|
||||
|
||||
source = ""
|
||||
target = ""
|
||||
response = api.policy_clone(source, target)
|
||||
print(response)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,44 @@
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', ".."))
|
||||
sys.path.append(project_root)
|
||||
|
||||
|
||||
from services.API import AirlockAPIWrapper
|
||||
from services.security import getAPI
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
def main():
|
||||
try:
|
||||
url = "https://172.17.22.240:3129"
|
||||
username = os.getenv("USERNAME")
|
||||
|
||||
if not url:
|
||||
raise ValueError("Missing URL in environment variables.")
|
||||
if not username:
|
||||
raise ValueError("Missing USERNAME in environment variables.")
|
||||
|
||||
logger.debug(f"Retrieved URL: {url}")
|
||||
logger.debug(f"Retrieved Username: {username}")
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
if username:
|
||||
api = AirlockAPIWrapper(
|
||||
base_url= url,
|
||||
api_key = getAPI(username, "AirlockTools"), # pyright: ignore[reportArgumentType]
|
||||
)
|
||||
|
||||
response = api.policy_find_all()
|
||||
response.to_csv("All_Policies.csv", index=False)
|
||||
|
||||
print(response)
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,75 @@
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
sys.path.append(project_root)
|
||||
|
||||
|
||||
from services.API import AirlockAPIWrapper
|
||||
from services.security import getAPI
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
def main():
|
||||
try:
|
||||
url = "https://172.17.22.240:3129"
|
||||
username = os.getenv("USERNAME")
|
||||
|
||||
if not url:
|
||||
raise ValueError("Missing URL in environment variables.")
|
||||
if not username:
|
||||
raise ValueError("Missing USERNAME in environment variables.")
|
||||
|
||||
logger.debug(f"Retrieved URL: {url}")
|
||||
logger.debug(f"Retrieved Username: {username}")
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
if username:
|
||||
api = AirlockAPIWrapper(
|
||||
base_url= url,
|
||||
api_key = getAPI(username, "AirlockTools"), # pyright: ignore[reportArgumentType]
|
||||
)
|
||||
"""
|
||||
Available script types are:
|
||||
|
||||
"batch",
|
||||
"powershell",
|
||||
"command",
|
||||
"vbscript",
|
||||
"javascript"
|
||||
,"windowsinstaller",
|
||||
"htmlapplication",
|
||||
"javaapplication",
|
||||
"windowsscriptcomponent",
|
||||
"compiledhtml",
|
||||
"shellscript",
|
||||
"dylib",
|
||||
"python"
|
||||
|
||||
"""
|
||||
groupid = "5aebf6a0-1d67-47b4-9c5f-2866ffca5671" #AT Testing
|
||||
script_custom = 1
|
||||
scripts_audit = [
|
||||
"batch",
|
||||
"powershell",
|
||||
"command",
|
||||
"vbscript",
|
||||
"javascript",
|
||||
"windowsinstaller",
|
||||
"javaapplication",
|
||||
"python"
|
||||
]
|
||||
|
||||
scripts_disabled = ["compiledhtml", "htmlapplication", "shellscript", "dylib","windowsscriptcomponent"]
|
||||
scripts_respect = []
|
||||
|
||||
response = api.policy_set_script_custom(groupid, script_custom, scripts_audit, scripts_disabled, scripts_respect)
|
||||
print(response)
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import json
|
||||
from utils.configmanager import (
|
||||
load_protected_config,
|
||||
get_protected_value,
|
||||
get_protected_json,
|
||||
PROTECTED_KEYS
|
||||
)
|
||||
from utils.setup import setup
|
||||
|
||||
def test_protected_config():
|
||||
print("🔒 Testing protected config loading...")
|
||||
protected = load_protected_config()
|
||||
assert isinstance(protected, dict), "Protected config should be a dictionary"
|
||||
for key in PROTECTED_KEYS:
|
||||
assert key in protected, f"Missing protected key: {key}"
|
||||
print(f"✔ {key} = {protected[key]}")
|
||||
|
||||
def test_json_parsing():
|
||||
print("\n🧪 Testing JSON parsing for POLICY_MAP_ENF_AUD...")
|
||||
policy = get_protected_json("POLICY_MAP_ENF_AUD")
|
||||
assert isinstance(policy, dict), "POLICY_MAP_ENF_AUD should be a dictionary"
|
||||
print(f"✔ POLICY_MAP_ENF_AUD = {json.dumps(policy, indent=2)}")
|
||||
|
||||
def test_setup_env():
|
||||
print("\n⚙️ Running setup() to validate environment setup...")
|
||||
working_dir = setup()
|
||||
assert working_dir.exists(), "Working directory should exist"
|
||||
print(f"✔ Working directory: {working_dir}")
|
||||
|
||||
print("\n🌍 Checking .env values (excluding protected)...")
|
||||
for key in os.environ:
|
||||
if key not in PROTECTED_KEYS:
|
||||
print(f"🔧 {key} = {os.environ[key]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_protected_config()
|
||||
test_json_parsing()
|
||||
test_setup_env()
|
||||
Reference in New Issue
Block a user