Skip to content

Exception when setting boolean option False or integer 0 value in Module Option #39

Description

@tterletskyy

Description

Sploitkit throws an exception when setting the boolean value False or integer 0 for Module Option. When setting True it works correctly.
Sploitkit version: sploitkit==0.6.0
Python version: 3.12+

Exceptions

% python -B main.py
Traceback (most recent call last):
  File ".../main.py", line 28, in <module>
    main()
  File ".../main.py", line 23, in main
    test.config['SEND_PAYLOAD'] = False
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 481, in __setitem__
    return c.__setitem__(key, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 67, in __setitem__
    key = self._setkey(key, value)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 159, in _setkey
    raise ValueError(f"Invalid value '{value}' for key '{key.name}'")
ValueError: Invalid value 'False' for key 'SEND_PAYLOAD'

############################################################################################

Traceback (most recent call last):
  File ".../main.py", line 28, in <module>
    main()
  File ".../main.py", line 23, in main
    test.config['SEND_PAYLOAD'] = 0
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 481, in __setitem__
    return c.__setitem__(key, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 67, in __setitem__
    key = self._setkey(key, value)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv_macos31244/lib/python3.12/site-packages/sploitkit/core/components/config.py", line 159, in _setkey
    raise ValueError(f"Invalid value '{value}' for key '{key.name}'")
ValueError: Invalid value '0' for key 'SEND_PAYLOAD'

Code

from pprint import pprint

from sploitkit import Config, Module, Option


class TestModule(Module):
    config = Config(
        {
            Option(
                name='SEND_PAYLOAD',
                description='Boolean or integer value',
                required=True,
            ): None,
        }
    )

    def run(self, *args, **kwargs) -> None:
        pprint(dict(self.config))


def main() -> None:
    test = TestModule()
    test.config['SEND_PAYLOAD'] = False # or 0
    test.run()


if __name__ == '__main__':
    main()

Activity

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

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions