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

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

jstucke
Copy link
Collaborator

@jstucke jstucke commented Sep 6, 2024

No description provided.

@jstucke jstucke requested a review from maringuu September 6, 2024 14:41
@jstucke jstucke self-assigned this Sep 6, 2024
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

@jstucke jstucke force-pushed the ipc-plugin-v1 branch 2 times, most recently from d83630a to bdfc638 Compare November 14, 2024 13:36
@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.85%. Comparing base (058e49f) to head (629bb50).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1263      +/-   ##
==========================================
- Coverage   92.42%   91.85%   -0.57%     
==========================================
  Files         379      378       -1     
  Lines       23661    20998    -2663     
==========================================
- Hits        21869    19288    -2581     
+ Misses       1792     1710      -82     

☔ 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
@maringuu maringuu merged commit cc67706 into master Dec 18, 2024
10 checks passed
@maringuu maringuu deleted the ipc-plugin-v1 branch December 18, 2024 10:15
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