eth-educators / ethstaker-deposit-cli

Secure key generation for deposits
https://eth-educators.github.io/ethstaker-deposit-cli/
Creative Commons Zero v1.0 Universal
2 stars 2 forks source link

Replace assert statements from source #64

Closed remyroy closed 4 weeks ago

remyroy commented 1 month ago

Running bandit on our repository revealed the following security issues:

>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/key_handling/key_derivation/mnemonic.py:130:16
129                 """
130                 assert reconstructed_mnemonic is None
131                 reconstructed_mnemonic = ' '.join([_index_to_word(full_word_list, index) for index in word_indices])

--------------------------------------------------
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/utils/intl.py:31:8
30          ans = reduce(dict.get, mapList, dataDict)
31          assert isinstance(ans, str)
32          return ans

--------------------------------------------------
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/utils/validation.py:138:8
137         num_int = int(num)  # Try cast to int
138         assert num_int == float(num)  # Check num is not float
139         assert low <= num_int < high  # Check num in range

--------------------------------------------------
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/utils/validation.py:139:8
138         assert num_int == float(num)  # Check num is not float
139         assert low <= num_int < high  # Check num in range
140         return num_int

--------------------------------------------------
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/utils/validation.py:266:8
265     try:
266         assert len(bls_withdrawal_credentials_bytes) == 32
267         assert bls_withdrawal_credentials_bytes[:1] == BLS_WITHDRAWAL_PREFIX

--------------------------------------------------
>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   More Info: https://bandit.readthedocs.io/en/1.7.8/plugins/b101_assert_used.html
   Location: ethstaker_deposit/utils/validation.py:267:8
266         assert len(bls_withdrawal_credentials_bytes) == 32
267         assert bls_withdrawal_credentials_bytes[:1] == BLS_WITHDRAWAL_PREFIX
268     except (ValueError, AssertionError):

--------------------------------------------------

Code scanned:
    Total lines of code: 2350
    Total lines skipped (#nosec): 0
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 6
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 6
Files skipped (0):