89db386ffe
- Migrated codebase to class-based architecture for better modularity and maintainability - Introduced system_config.json for centralized configuration (required for runtime) - Added structured working directories for improved file organization - Significantly reduced reliance on Parquet; replaced with alternative data handling - Implemented security improvements across modules - Several TODOs remain in the main script for future enhancements - Linter formatting affected readability in some files (e.g., utils); cleanup is on the agenda
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
# Copyright (C) 2025 James Brotosky, Brandon Wickline
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
import json
|
|
|
|
"""
|
|
Policy model representing policy data and relationships.
|
|
"""
|
|
|
|
|
|
class Policy:
|
|
def __init__(self, groupid, hidden, name, parent):
|
|
self.groupid = groupid
|
|
self.hidden = hidden
|
|
self.name = name
|
|
self.parent = parent
|
|
|
|
def __repr__(self):
|
|
# Show all current attributes, including dynamically added ones
|
|
attrs = ", ".join(f"{key}={repr(value)}" for key, value in self.__dict__.items())
|
|
return f"<Execution({attrs})>"
|
|
|
|
def to_dict(self):
|
|
# Return all attributes as a dictionary
|
|
return self.__dict__
|
|
|
|
def to_json(self):
|
|
# Convert to JSON string, handling non-serializable types gracefully
|
|
return json.dumps(self.to_dict(), default=str)
|
|
|
|
|
|
class Allowlist:
|
|
"""
|
|
Represents Allowlist
|
|
"""
|
|
|
|
def __init__(self, applicationid, name, version):
|
|
self.applicationid = applicationid
|
|
self.name = name
|
|
self.version = version
|
|
|
|
def __repr__(self):
|
|
# Show all current attributes, including dynamically added ones
|
|
attrs = ", ".join(f"{key}={repr(value)}" for key, value in self.__dict__.items())
|
|
return f"<Execution({attrs})>"
|
|
|
|
def to_dict(self):
|
|
# Return all attributes as a dictionary
|
|
return self.__dict__
|
|
|
|
def to_json(self):
|
|
# Convert to JSON string, handling non-serializable types gracefully
|
|
return json.dumps(self.to_dict(), default=str)
|