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

fix(filters): int conversion without check #4482

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

Conversation

geyslan
Copy link
Member

@geyslan geyslan commented Jan 10, 2025

Close: #4481

1. Explain what the PR does

4bef591 fix(filters): int conversion without check

This silences some CodeQL "Incorrect conversion between integer types"
warnings.

2. Explain how to test it

3. Other comments

This silences some CodeQL "Incorrect conversion between integer types"
warnings.
@@ -70,11 +71,16 @@ func attachSuspiciousSyscallSourceProbes(t *Tracee, eventParams []map[string]fil
if err != nil {
return err
}
if !events.Core.IsDefined(events.ID(syscallID)) {
if syscallID < 0 || syscallID > math.MaxInt32 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this kind of check be resolved inside the IsDefined method? Is this the particular code which fixes the CodeQL issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't this kind of check be resolved inside the IsDefined method?

IsDefined only checks for the existence of a events.ID value, it's agnostic to the origin of that value, so I believe it's sane to check it right after the Atoi conversion, since we're truncating the output (int - 64) to events.ID (int32).

Is this the particular code which fixes the CodeQL issue?

Yep. It's an attempt. Let's see if the issue is closed automagically after this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW, I would like to ask you if these conversions https://github.com/aquasecurity/tracee/security/code-scanning/2 are ok. I mean, if they are the full size of those values, why the API providing them uses int (or other larger types) instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeQL "Incorrect conversion between integer types" warnings
2 participants