-
-
Notifications
You must be signed in to change notification settings - Fork 49
feat: add permission auditor & fixer final version (implements #446) #536
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
Draft
altynai9128
wants to merge
21
commits into
cortexlinux:main
Choose a base branch
from
altynai9128:permission-simple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8746c48
feat: add permission auditor & fixer
altynai9128 2191e3f
style: apply black formatting and fix ruff warnings
altynai9128 990b727
feat: implement Permission Auditor & Fixer (Issue #446)
altynai9128 3eb0961
Add: new tests, updated old once for the full coverage
altynai9128 9905c8f
Add: added one more test feature
altynai9128 9106230
FIX: correct Path mocking in tests
altynai9128 bef7c42
fix: correct test for DockerPermissionHandler method
altynai9128 10a13c3
Fix: fixed docker tests again
altynai9128 c9aeed5
ix: address CodeRabbit review comments
altynai9128 b3e8926
fix: complete CodeRabbit review feedback
altynai9128 0508dce
fix: fixed the last coderabbit issue
altynai9128 99e9fbf
fix: final adjustments
altynai9128 8ac1364
Merge branch 'main' into permission-simple
Anshgrover23 e8d162a
fix: fixed conflicts
altynai9128 c5267c1
Merge branch 'permission-simple' of https://github.com/altynai9128/co…
altynai9128 a10561c
chore: remove out-of-scope files (fix_indents.py, test_hwprofiler.py)
altynai9128 cfad74e
Merge branch 'main' into permission-simple
altynai9128 0047451
Fix syntax error
altynai9128 40491d9
Merge branch 'permission-simple' of https://github.com/altynai9128/co…
altynai9128 beb2596
Fix syntax errors in cli.py
altynai9128 2ba682b
Fix syntax errors in cli.py
altynai9128 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,71 @@ | ||
| """ | ||
| Permission Auditor & Fixer module. | ||
| """ | ||
|
|
||
| from typing import Any | ||
|
|
||
|
|
||
| class PermissionAuditor: | ||
| """Proxy class for PermissionAuditor with lazy loading.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| from .auditor_fixer import PermissionAuditor as RealPermissionAuditor | ||
|
|
||
| return RealPermissionAuditor(*args, **kwargs) | ||
|
|
||
|
|
||
| class DockerPermissionHandler: | ||
| """Proxy class for DockerPermissionHandler with lazy loading.""" | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| from .docker_handler import DockerPermissionHandler as RealDockerPermissionHandler | ||
|
|
||
| return RealDockerPermissionHandler(*args, **kwargs) | ||
|
|
||
|
|
||
| PermissionManager = PermissionAuditor | ||
| PermissionFixer = PermissionAuditor | ||
|
|
||
|
|
||
| def scan_path(path: str) -> Any: | ||
| """ | ||
| Simplified interface to scan a path for permission issues. | ||
|
|
||
| Args: | ||
| path: Directory path to scan | ||
|
|
||
| Returns: | ||
| Scan results from PermissionAuditor.scan_directory() | ||
| """ | ||
| auditor = PermissionAuditor() | ||
| return auditor.scan_directory(path) | ||
|
|
||
|
|
||
| def analyze_permissions(path: str) -> dict[str, Any]: | ||
| """ | ||
| Analyze permissions and return detailed report. | ||
|
|
||
| Args: | ||
| path: Directory path to analyze | ||
|
|
||
| Returns: | ||
| Dictionary with scan results and analysis | ||
| """ | ||
| auditor = PermissionAuditor() | ||
| scan = auditor.scan_directory(path) | ||
| return { | ||
| "path": path, | ||
| "auditor": auditor, | ||
| "scan": scan, | ||
| "issues_count": len(scan.get("world_writable", [])) + len(scan.get("dangerous", [])), | ||
| } | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "PermissionAuditor", | ||
| "DockerPermissionHandler", | ||
| "PermissionManager", | ||
| "PermissionFixer", | ||
| "scan_path", | ||
| "analyze_permissions", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.