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

feat: converted ipc plugin to new base class #1263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jstucke
Copy link
Collaborator

@jstucke jstucke commented Sep 6, 2024

No description provided.

src/plugins/analysis/ipc/code/ipc_analyzer.py Outdated Show resolved Hide resolved
src/plugins/analysis/ipc/code/ipc_analyzer.py Outdated Show resolved Hide resolved
src/plugins/analysis/ipc/code/ipc_analyzer.py Outdated Show resolved Hide resolved
Comment on lines 10 to 16
'targets': [
{'name': 'whoami', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]},
{'name': 'ls', 'ipc_calls': [{'type': 'system', 'arguments': ['-l']}]},
{'name': 'echo', 'ipc_calls': [{'type': 'system', 'arguments': ['hello']}]},
{'name': 'id', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]},
{'name': 'pwd', 'ipc_calls': [{'type': 'system', 'arguments': ['']}]},
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target of the IPC (usually a file path or address)

How do these names (whoami, ls, etc.) match the documentation?

Comment on lines 436 to 447
def sort_dict_list_by_key(dict_list: list[dict], key: Any) -> list[dict]:
types = {type(d.get(key)) for d in dict_list if key in d}
if types not in [set(), {str}, {int}]:
raise ValueError(f'Dict values must be of the same type, not {types}')
return sorted(dict_list, key=lambda d: d.get(key, -9999 if types == {int} else ''))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -9999 looks suspicious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure what would be appropriate here. I was hesitant to use 0 (in case there actually are negative entries) and there is no minimum int in python 3. I'm open for suggestions. The 9999 just seemed funny 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use -float("inf") but why should this function support this at all?
I think sorting by a key that does not exist should not be supported.
IIUC the function is only used by a single plugin which guarantees this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it so that it converts the values to string while sorting which makes everything easier

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.92%. Comparing base (58fe736) to head (29b877e).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1263      +/-   ##
==========================================
- Coverage   92.25%   91.92%   -0.34%     
==========================================
  Files         376      376              
  Lines       22054    21057     -997     
==========================================
- Hits        20346    19356     -990     
+ Misses       1708     1701       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

also added new jinja filter for sorting dict lists by key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants