Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic security prompts #178

Merged
merged 8 commits into from
Oct 27, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
refactor: updated permission flags and access types for pyapi only.
  • Loading branch information
Almas-Ali committed Oct 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b8fbae72153364b55b125bfe67fc7127e594c074
2 changes: 1 addition & 1 deletion core/builtin_funcs.py
Original file line number Diff line number Diff line change
@@ -428,7 +428,7 @@ def execute_type(self, exec_ctx: Context) -> RTResult[Value]:

@args(["code", "ns"])
def execute_pyapi(self, exec_ctx: Context) -> RTResult[Value]:
security.security_prompt("pyapi_requests")
security.security_prompt("pyapi_access")

res = RTResult[Value]()

6 changes: 3 additions & 3 deletions core/security.py
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
from core.colortools import Log

# Define all types of security prompts
SecurityPromptType = Literal["pyapi_requests", "disk_access", "network_access"]
SecurityPromptType = Literal["pyapi_access", "disk_access", "network_access"]
type_messages: dict[str, str] = {
"pyapi_requests": "This program is attempting to use the Python API",
"pyapi_access": "This program is attempting to use the Python API",
"disk_access": "This program is attempting to access the disk",
"network_access": "This program is attempting to access the network"
}
@@ -15,7 +15,7 @@

# !!! Only used for tests !!!
def allow_all_permissions() -> None:
allowed["pyapi_requests"] = True
allowed["pyapi_access"] = True
allowed["disk_access"] = True
allowed["network_access"] = True

2 changes: 1 addition & 1 deletion radon.py
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ def main(argv: list[str]) -> None:
case "--allow-disk" | "-D":
base_core.security.allowed["disk_access"] = True
case "--allow-py" | "-P":
base_core.security.allowed["pyapi_requests"] = True
base_core.security.allowed["pyapi_access"] = True
case "--allow-network" | "-W":
base_core.security.allowed["network_access"] = True
case _:
Loading