Merge pull request #1639 from crytic/no-warn-immut-string

do not recommend to make string immutable
pull/1691/head
Feist Josselin 2 years ago committed by GitHub
commit c2cb22d3ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      slither/detectors/variables/unchanged_state_variables.py
  2. 4
      tests/detectors/immutable-states/0.4.25/immut_state_variables.sol
  3. 4
      tests/detectors/immutable-states/0.5.16/immut_state_variables.sol
  4. 4
      tests/detectors/immutable-states/0.6.11/immut_state_variables.sol
  5. 4
      tests/detectors/immutable-states/0.7.6/immut_state_variables.sol
  6. 4
      tests/detectors/immutable-states/0.8.0/immut_state_variables.sol
  7. 24
      tests/detectors/immutable-states/0.8.0/immut_state_variables.sol.0.8.0.CouldBeImmutable.json

@ -118,8 +118,9 @@ class UnchangedStateVariables:
self.constant_candidates.append(v)
elif (
v in constructor_variables_written or v in variables_initialized
) and version.parse(self.compilation_unit.solc_version) >= version.parse(
"0.6.5"
not v.type.is_dynamic
and version.parse(self.compilation_unit.solc_version)
>= version.parse("0.6.5")
and (v in constructor_variables_written or v in variables_initialized)
):
self.immutable_candidates.append(v)

@ -45,9 +45,11 @@ contract MyConc{
uint not_constant_2 = getNumber();
uint not_constant_3 = 10 + block.number;
uint not_constant_5;
string cannote_be_immutable;
constructor(uint b) public {
constructor(uint b, string memory c) public {
not_constant_5 = b;
cannote_be_immutable = c;
}
function getNumber() public returns(uint){

@ -46,9 +46,11 @@ contract MyConc{
uint not_constant_2 = getNumber();
uint not_constant_3 = 10 + block.number;
uint not_constant_5;
string cannote_be_immutable;
constructor(uint b) public {
constructor(uint b, string memory c) public {
not_constant_5 = b;
cannote_be_immutable = c;
}
function getNumber() public returns(uint){

@ -67,9 +67,11 @@ contract Good {
uint immutable should_be_immutable_3 = 10 + block.number;
B immutable should_be_immutable_4 = new B();
uint immutable should_be_immutable_5;
string cannote_be_immutable;
constructor(uint b) public {
constructor(uint b, string memory c) public {
should_be_immutable_5 = b;
cannote_be_immutable = c;
}
function getNumber() public returns(uint){

@ -66,9 +66,11 @@ contract Good {
uint immutable should_be_immutable_3 = 10 + block.number;
B immutable should_be_immutable_4 = new B();
uint immutable should_be_immutable_5;
string cannote_be_immutable;
constructor(uint b) {
constructor(uint b, string memory c) {
should_be_immutable_5 = b;
cannote_be_immutable = c;
}
function getNumber() public returns(uint){

@ -44,9 +44,11 @@ contract Bad {
uint should_be_immutable_2 = getNumber();
uint should_be_immutable_3 = 10 + block.number;
uint should_be_immutable_5;
string cannote_be_immutable;
constructor(uint b) {
constructor(uint b, string memory c) {
should_be_immutable_5 = b;
cannote_be_immutable = c;
}
function getNumber() public returns(uint){

@ -24,7 +24,7 @@
"name": "Bad",
"source_mapping": {
"start": 718,
"length": 493,
"length": 577,
"filename_relative": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
@ -49,7 +49,9 @@
53,
54,
55,
56
56,
57,
58
],
"starting_column": 1,
"ending_column": 2
@ -90,7 +92,7 @@
"name": "Bad",
"source_mapping": {
"start": 718,
"length": 493,
"length": 577,
"filename_relative": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
@ -115,7 +117,9 @@
53,
54,
55,
56
56,
57,
58
],
"starting_column": 1,
"ending_column": 2
@ -156,7 +160,7 @@
"name": "Bad",
"source_mapping": {
"start": 718,
"length": 493,
"length": 577,
"filename_relative": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
@ -181,7 +185,9 @@
53,
54,
55,
56
56,
57,
58
],
"starting_column": 1,
"ending_column": 2
@ -222,7 +228,7 @@
"name": "Bad",
"source_mapping": {
"start": 718,
"length": 493,
"length": 577,
"filename_relative": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/immutable-states/0.8.0/immut_state_variables.sol",
@ -247,7 +253,9 @@
53,
54,
55,
56
56,
57,
58
],
"starting_column": 1,
"ending_column": 2

Loading…
Cancel
Save