WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
11 changes: 8 additions & 3 deletions src/detectors/builtin/suspiciousMessageMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ export class SuspiciousMessageMode extends ASTDetector {
flagsUsed.add(flagName);
break;
case "number":
let suggestion: string = `Replace integer literal \`${e.value}\` with symbolic flag constants`;
if (e.value === 64n) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's use constEval, just for the case

suggestion = "Replace `64` with `SendRemainingValue`";
} else if (e.value === 128n) {
suggestion = "Replace `128` with `SendRemainingBalance`";
}
warnings.push(
this.makeWarning(
"Integer literals should not be used in mode expression; use symbolic constants instead",
"Integer literals should not be used in mode expression",
e.loc,
{
suggestion:
"Replace integer literals with symbolic flag constants",
suggestion,
},
),
);
Expand Down
8 changes: 4 additions & 4 deletions test/detectors/SuspiciousMessageMode.expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ test/detectors/SuspiciousMessageMode.tact:25:19:
Help: Use the '|' operator (bitwise OR) to combine flags
See: https://nowarp.io/tools/misti/docs/detectors/SuspiciousMessageMode

[MEDIUM] SuspiciousMessageMode: Integer literals should not be used in mode expression; use symbolic constants instead
[MEDIUM] SuspiciousMessageMode: Integer literals should not be used in mode expression.
test/detectors/SuspiciousMessageMode.tact:34:19:
33 | value: 0,
> 34 | mode: 64 // Bad: Integer literal instead of symbolic constant
^
35 | });
Help: Replace integer literals with symbolic flag constants
Help: Replace `64` with `SendRemainingValue`
See: https://nowarp.io/tools/misti/docs/detectors/SuspiciousMessageMode

[MEDIUM] SuspiciousMessageMode: Mode expression should only contain the '|' operator
Expand All @@ -43,13 +43,13 @@ test/detectors/SuspiciousMessageMode.tact:52:40:
Help: Use each flag at most once in the mode expression
See: https://nowarp.io/tools/misti/docs/detectors/SuspiciousMessageMode

[MEDIUM] SuspiciousMessageMode: Integer literals should not be used in mode expression; use symbolic constants instead
[MEDIUM] SuspiciousMessageMode: Integer literals should not be used in mode expression
test/detectors/SuspiciousMessageMode.tact:52:61:
51 | value: 0,
> 52 | mode: SendRemainingValue + SendRemainingValue + 64 // Bad: Duplicate flags, '+' operator, integer literal
^
53 | });
Help: Replace integer literals with symbolic flag constants
Help: Replace `64` with `SendRemainingValue`
See: https://nowarp.io/tools/misti/docs/detectors/SuspiciousMessageMode

[MEDIUM] SuspiciousMessageMode: Mode expression should only contain the '|' operator
Expand Down