mushorg / conpot

ICS/SCADA honeypot
GNU General Public License v2.0
1.21k stars 409 forks source link

Move a bunch of files to more appropriate locations #547

Closed srenfo closed 2 years ago

srenfo commented 3 years ago

Continuing the series of cleanup PRs, this one mostly moves and renames files with very little code impact past rewriting imports.

  1. Move core.xsd out of the tests directory and rename it. It is now conpot/template.xsd, though it could be argued it should be conpot/core/template.xsd... but it's being used by bin/conpot and not technically by core. Either way it brings it more in line with the protocol XSDs like conpot/protocols/ftp/ftp.xsd. This removes conpot/tests/template_schemas/ where it was the only file.
  2. Move Proxy from conpot.emulators.proxy to the more fitting conpot.protocols.proxy. Also merge conpot.protocols.misc.ascii_decoder.AsciiDecoder into conpot.protocols.proxy. This removes conpot.protocols.misc, where AsciiDecoder was the only module.
  3. Move conpot.protocols.kamstrup.usage_simulator.UsageSimulator from protocols to emulators. Its usage (heh) leads me to believe it's an emulator (sic) and thus belongs in the emulators directory. https://github.com/mushorg/conpot/blob/237b1563eeffc42c8741d5a078a2fa22b1dff772/conpot/templates/kamstrup_382/template.xml#L13-L15
  4. Remove kamstrup special handling by moving the protocols to dedicated directories. That is, it goes from
    protocols/
    ...
    ├── kamstrup
    │   ├── management_protocol
    │   └── meter_protocol
    ...
    └── tftp

    to

    protocols/
    ...
    ├── kamstrup_management
    ├── kamstrup_meter
    ...
    └── tftp
  5. Unify conpot.helpers and conpot.utils. I think it's fine for either to exist but confusing for both to exist. This involves minimal code movement.
    1. conpot.helpers is renamed conpot.utils.networking (I'm open for a better name here), except that is then longer an appropriate location for months_map, which is thus moved to conpot.core.filesystem, the only place it's being used.
    2. get_interface_ip is moved from conpot.utils.ext_ip to the now more appropriate conpot.utils.networking.
  6. Some logger test files were prefixed test_logger_, while others were not. They're now all in line. The same is done for test_utils_.
  7. conpot.core.loggers.log_worker is not a logger and is thus promoted to conpot.core.log_worker. This one in particular is quite nit-picky.

If any of this proves controversial I can pull the offending commit. Only the kamstrup changes are a little intertwined.

glaslos commented 2 years ago

Great work! Apologies for the late review.