#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/plugin/PluginAuditManager.hpp>
Public Types | |
| using | PermissionPrompt = std::function<bool(const std::string& event_name, const std::vector<std::string>& targets)> |
| using | PermissionMessagePrompt = std::function<bool(const std::string& message)> |
Public Member Functions | |
| void | install_hook () |
| void | set_current_plugin (const std::string &plugin_key) |
| std::string | current_plugin () const |
| void | clear_current_plugin () |
| void | set_current_capability (const std::string &capability_name) |
| std::string | current_capability () const |
| void | clear_current_capability () |
| void | add_global_allowed_root (const boost::filesystem::path &root, bool allow_write=true) |
| void | add_scoped_allowed_root (const boost::filesystem::path &root, bool allow_write=true) |
| void | add_denied_filename (const std::string &filename) |
| bool | is_denied_filename (const boost::filesystem::path &candidate) const |
| void | add_denied_path_keyword (const std::string &keyword) |
| bool | is_denied_path_keyword (const boost::filesystem::path &candidate) const |
| bool | is_denied_path (const boost::filesystem::path &candidate) const |
| AuditDecision | check_path_access (const boost::filesystem::path &candidate, bool is_write) |
| AuditDecision | check_open (const std::string &path, const std::string &mode) |
| bool | request_permissions (const std::string &plugin_key, const PluginPermissions &requested) |
| bool | request_network_permissions (const std::string &plugin_key, const std::vector< std::string > &urls) |
| void | report_violation (const AuditViolation &violation) |
| bool | audit_denial_pending () const |
| void | clear_audit_denial () |
| void | clear_last_violation () |
| bool | last_violation (AuditViolation &violation) const |
| void | record_root_frame () |
| bool | covered_by_root_frame () const |
| bool | releasing_frames () const |
Static Public Member Functions | |
| static PluginAuditManager & | instance () |
| static std::vector< std::string > | default_denied_filenames () |
| static std::vector< std::string > | default_denied_path_keywords () |
| static std::string | normalize_network_url (const std::string &url) |
| static bool | network_permission_matches (const std::vector< std::string > &granted, const std::string &target) |
| static bool | is_stdlib_file (const std::string &filename) |
| static void | set_permission_prompt_for_testing (PermissionPrompt prompt) |
| static void | set_permission_message_prompt_for_testing (PermissionMessagePrompt prompt) |
Public Attributes | |
| bool | verbose_events = true |
Private Member Functions | |
| PluginAuditManager ()=default | |
| void | release_frames (std::vector< PyObject * > &frames) |
Static Private Member Functions | |
| static int | audit_hook (const char *event, PyObject *args, void *user_data) |
| static bool | is_stdlib_path (const boost::filesystem::path &path) |
Private Attributes | |
| std::mutex | m_mutex |
| std::vector< AllowedRoot > | m_global_allowed_roots |
| std::vector< std::string > | m_denied_filenames |
| std::vector< std::string > | m_denied_path_keywords |
Static Private Attributes | |
| static std::string | m_current_plugin_key = "" |
| static std::string | m_current_capability_name = "" |
| static std::vector< AllowedRoot > | m_scoped_allowed_roots |
| static std::vector< PyObject * > | m_root_frames |
| static int | m_releasing_frames = 0 |
| static bool | m_audit_denial_pending = false |
| static bool | m_has_last_violation = false |
| static AuditViolation | m_last_violation |
Friends | |
| class | ScopedPluginAuditContext |
| using Slic3r::PluginAuditManager::PermissionMessagePrompt = std::function<bool(const std::string& message)> |
| using Slic3r::PluginAuditManager::PermissionPrompt = std::function<bool(const std::string& event_name, const std::vector<std::string>& targets)> |
|
privatedefault |
| void Slic3r::PluginAuditManager::add_denied_filename | ( | const std::string & | filename | ) |
References m_denied_filenames, and m_mutex.
Referenced by install_hook().
| void Slic3r::PluginAuditManager::add_denied_path_keyword | ( | const std::string & | keyword | ) |
References m_denied_path_keywords, and m_mutex.
Referenced by install_hook().
| void Slic3r::PluginAuditManager::add_global_allowed_root | ( | const boost::filesystem::path & | root, |
| bool | allow_write = true ) |
References m_global_allowed_roots, and m_mutex.
Referenced by install_hook().
| void Slic3r::PluginAuditManager::add_scoped_allowed_root | ( | const boost::filesystem::path & | root, |
| bool | allow_write = true ) |
References current_plugin(), and m_scoped_allowed_roots.
Referenced by Slic3r::PySlicingPipelinePluginCapabilityTrampoline::execute().
| bool Slic3r::PluginAuditManager::audit_denial_pending | ( | ) | const |
References m_audit_denial_pending.
Referenced by Slic3r::invoke_script_execute().
|
staticprivate |
References PluginAuditManager(), Slic3r::PluginAuditDetail::audit_plugin_event(), current_plugin(), Slic3r::event_category(), m_root_frames, Slic3r::None, Slic3r::PluginAuditDetail::open_category(), release_frames(), Slic3r::PluginAuditDetail::take_returned_frames(), Slic3r::trace(), and verbose_events.
Referenced by install_hook().
| AuditDecision Slic3r::PluginAuditManager::check_open | ( | const std::string & | path, |
| const std::string & | mode ) |
References check_path_access().
| AuditDecision Slic3r::PluginAuditManager::check_path_access | ( | const boost::filesystem::path & | candidate, |
| bool | is_write ) |
References current_plugin(), is_denied_filename(), is_denied_path_keyword(), Slic3r::is_inside_allowed_root(), is_stdlib_path(), m_global_allowed_roots, m_mutex, and m_scoped_allowed_roots.
Referenced by check_open().
| void Slic3r::PluginAuditManager::clear_audit_denial | ( | ) |
References m_audit_denial_pending.
Referenced by Slic3r::invoke_script_execute().
| void Slic3r::PluginAuditManager::clear_current_capability | ( | ) |
References m_current_capability_name.
| void Slic3r::PluginAuditManager::clear_current_plugin | ( | ) |
References m_current_plugin_key.
Referenced by Slic3r::invoke_script_execute().
| void Slic3r::PluginAuditManager::clear_last_violation | ( | ) |
References m_has_last_violation, and m_last_violation.
| bool Slic3r::PluginAuditManager::covered_by_root_frame | ( | ) | const |
References Slic3r::PluginAuditDetail::is_stdlib_frame(), m_root_frames, and Slic3r::PluginAuditDetail::stack_frames().
Referenced by Slic3r::PluginAuditDetail::audit_plugin_event().
| std::string Slic3r::PluginAuditManager::current_capability | ( | ) | const |
References m_current_capability_name.
| std::string Slic3r::PluginAuditManager::current_plugin | ( | ) | const |
References m_current_plugin_key.
Referenced by add_scoped_allowed_root(), audit_hook(), Slic3r::PluginAuditDetail::audit_plugin_event(), check_path_access(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::plater_notification(), Slic3r::host_bindings::register_plugin(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_dock_panel(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_progress_dialog(), and Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_window().
|
static |
References GCODEVIEWER_APP_KEY, and Slic3r::secret_constants::USER_SECRET_FILENAME.
Referenced by install_hook().
|
static |
Referenced by install_hook().
| void Slic3r::PluginAuditManager::install_hook | ( | ) |
References add_denied_filename(), add_denied_path_keyword(), add_global_allowed_root(), audit_hook(), Slic3r::PluginAuditDetail::collect_stdlib_dirs(), Slic3r::data_dir(), default_denied_filenames(), default_denied_path_keywords(), and Slic3r::resources_dir().
Referenced by Slic3r::PythonInterpreter::initialize().
|
static |
References PluginAuditManager().
Referenced by Slic3r::ScopedPluginAuditContext::ScopedPluginAuditContext(), Slic3r::ScopedPluginAuditContext::~ScopedPluginAuditContext(), Slic3r::PySlicingPipelinePluginCapabilityTrampoline::execute(), Slic3r::PythonPluginBridge::finalize_plugin_capture(), Slic3r::PythonInterpreter::initialize(), Slic3r::invoke_script_execute(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::plater_notification(), Slic3r::host_bindings::register_plugin(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_dock_panel(), Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_progress_dialog(), and Slic3r::anonymous_namespace{PluginHostUi.cpp}::ui_create_window().
| bool Slic3r::PluginAuditManager::is_denied_filename | ( | const boost::filesystem::path & | candidate | ) | const |
References m_denied_filenames, and m_mutex.
Referenced by check_path_access(), and is_denied_path().
| bool Slic3r::PluginAuditManager::is_denied_path | ( | const boost::filesystem::path & | candidate | ) | const |
References is_denied_filename(), and is_denied_path_keyword().
Referenced by Slic3r::PluginAuditDetail::audit_plugin_event().
| bool Slic3r::PluginAuditManager::is_denied_path_keyword | ( | const boost::filesystem::path & | candidate | ) | const |
References Slic3r::data_dir(), Slic3r::empty(), Slic3r::has_denied_config_extension(), m_denied_path_keywords, and m_mutex.
Referenced by check_path_access(), and is_denied_path().
|
static |
References Slic3r::PluginAuditDetail::s_site_package_dirs, Slic3r::PluginAuditDetail::s_stdlib_dirs, and Slic3r::PluginAuditDetail::s_stdlib_file_verdicts.
Referenced by Slic3r::PluginAuditDetail::is_stdlib_frame().
|
staticprivate |
References Slic3r::PluginAuditDetail::s_site_package_dirs, and Slic3r::PluginAuditDetail::s_stdlib_dirs.
Referenced by check_path_access().
| bool Slic3r::PluginAuditManager::last_violation | ( | AuditViolation & | violation | ) | const |
References m_has_last_violation, and m_last_violation.
|
static |
References Slic3r::ascii_lower(), Slic3r::network_host_from_target(), normalize_network_url(), and Slic3r::without_ipv6_brackets().
Referenced by Slic3r::PluginAuditDetail::has_network_permission().
|
static |
References Slic3r::ascii_lower(), and Slic3r::host_from_authority().
Referenced by Slic3r::bind_python_api(), network_permission_matches(), and request_network_permissions().
| void Slic3r::PluginAuditManager::record_root_frame | ( | ) |
References Slic3r::PluginAuditDetail::is_stdlib_frame(), and m_root_frames.
Referenced by Slic3r::PluginAuditDetail::audit_plugin_event().
|
private |
References m_audit_denial_pending, m_has_last_violation, m_last_violation, and m_releasing_frames.
Referenced by Slic3r::ScopedPluginAuditContext::~ScopedPluginAuditContext(), and audit_hook().
| bool Slic3r::PluginAuditManager::releasing_frames | ( | ) | const |
References m_releasing_frames.
Referenced by Slic3r::PluginAuditDetail::decide_audited_event().
| void Slic3r::PluginAuditManager::report_violation | ( | const AuditViolation & | violation | ) |
References Slic3r::AuditViolation::event_name, m_audit_denial_pending, m_has_last_violation, m_last_violation, Slic3r::AuditViolation::plugin_key, and Slic3r::AuditViolation::reason.
| bool Slic3r::PluginAuditManager::request_network_permissions | ( | const std::string & | plugin_key, |
| const std::vector< std::string > & | urls ) |
References Slic3r::PluginPermissions::network_http, normalize_network_url(), and request_permissions().
| bool Slic3r::PluginAuditManager::request_permissions | ( | const std::string & | plugin_key, |
| const PluginPermissions & | requested ) |
References Slic3r::PluginAuditDetail::absolute_tree_grant(), Slic3r::PluginAuditDetail::audit_message(), Slic3r::PluginPermissions::fs_read, Slic3r::PluginPermissions::fs_readwrite, Slic3r::FsRead, Slic3r::FsReadWrite, Slic3r::PluginAuditDetail::has_network_permission(), Slic3r::PluginAuditDetail::has_permission(), Slic3r::Http, Slic3r::PluginManager::instance(), Slic3r::is_network_category(), Slic3r::PluginDescriptor::name, Slic3r::PluginPermissions::network_http, Slic3r::PluginPermissions::network_socket, Slic3r::PluginAuditDetail::permission_list_for(), Slic3r::PluginInstallState::permissions, Slic3r::PluginDescriptor::plugin_root, Slic3r::PluginPermissions::process, Slic3r::ProcessCreate, Slic3r::PluginAuditDetail::prompt_for_permission_message(), Slic3r::read_install_state(), Slic3r::PluginAuditDetail::s_permission_message_prompt_for_testing, Slic3r::PluginAuditDetail::seed_install_metadata(), Slic3r::Socket, Slic3r::Threading, Slic3r::PluginPermissions::threading, and Slic3r::write_install_state().
Referenced by request_network_permissions().
| void Slic3r::PluginAuditManager::set_current_capability | ( | const std::string & | capability_name | ) |
References m_current_capability_name.
Referenced by Slic3r::ScopedPluginAuditContext::ScopedPluginAuditContext(), and Slic3r::ScopedPluginAuditContext::~ScopedPluginAuditContext().
| void Slic3r::PluginAuditManager::set_current_plugin | ( | const std::string & | plugin_key | ) |
References m_current_plugin_key.
Referenced by Slic3r::ScopedPluginAuditContext::ScopedPluginAuditContext(), and Slic3r::ScopedPluginAuditContext::~ScopedPluginAuditContext().
|
static |
|
static |
References Slic3r::PluginAuditDetail::s_permission_prompt_for_testing.
|
friend |
References ScopedPluginAuditContext.
Referenced by ScopedPluginAuditContext.
|
thread_localstaticprivate |
Referenced by audit_denial_pending(), clear_audit_denial(), release_frames(), and report_violation().
|
thread_localstaticprivate |
Referenced by clear_current_capability(), current_capability(), and set_current_capability().
|
thread_localstaticprivate |
Referenced by clear_current_plugin(), current_plugin(), and set_current_plugin().
|
private |
Referenced by add_denied_filename(), and is_denied_filename().
|
private |
Referenced by add_denied_path_keyword(), and is_denied_path_keyword().
|
private |
Referenced by add_global_allowed_root(), and check_path_access().
|
thread_localstaticprivate |
Referenced by clear_last_violation(), last_violation(), release_frames(), and report_violation().
|
thread_localstaticprivate |
Referenced by clear_last_violation(), last_violation(), release_frames(), and report_violation().
|
mutableprivate |
|
thread_localstaticprivate |
Referenced by release_frames(), and releasing_frames().
|
thread_localstaticprivate |
|
thread_localstaticprivate |
| bool Slic3r::PluginAuditManager::verbose_events = true |
Referenced by audit_hook().