NetExec icon indicating copy to clipboard operation
NetExec copied to clipboard

Update Ruff and Fix Linting

Open NeffIsBack opened this issue 10 months ago • 5 comments

Description

The pinned ruff version is super old by now. This PR updates ruff to the newest version and fixes all new rules that have been selected. This should probably be merged after 1.4.0 is released

Excluded Rules:

  • FURB: Makes code a lot more complicated
  • D413: Unnecessary newlines in docstrings
  • RUF059: Allow unused variables because it is good to know which values are unpacked from content
  • A004: It complains about sys.exit shadowing python build-in exit(), which we have explicitly chose not to use

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update
  • [ ] This requires a third party update (such as Impacket, Dploot, lsassy, etc)
  • [x] LINTING

How Has This Been Tested?

coerce_plus and pfx auth were tested against GOAD, but before merging extensive testing should still be done.

Checklist:

  • [x] I have ran Ruff against my changes (via poetry: poetry run python -m ruff check . --preview, use --fix to automatically fix what it can)
  • [ ] New and existing e2e tests pass locally with my changes
  • [x] My code follows the style guidelines of this project (should be covered by Ruff above)
  • [ ] I have performed a self-review of my own code

NeffIsBack avatar Apr 03 '25 16:04 NeffIsBack

I'll have to run FURB myself to see what changes it does, but from looking at it, it looks like its a good way to update old crappy code to modern Pythonic conventions.

Marshall-Hallenbeck avatar Apr 03 '25 17:04 Marshall-Hallenbeck

I'll have to run FURB myself to see what changes it does, but from looking at it, it looks like its a good way to update old crappy code to modern Pythonic conventions.

Try it out, but i disabled 3 rules each after another, because imo they made the code much more complex and nonuniform. E.g. this: image image

Not sure if using "Path" is much better when everyone is used to "open". Also half of the rules are "unstable", for now, so maybe not even here to stay?

NeffIsBack avatar Apr 03 '25 17:04 NeffIsBack

If they're considered "unstable" yeah, probably not a good idea to use them. Path is the new way to use files with Python, so we should move to that.

Marshall-Hallenbeck avatar Apr 03 '25 17:04 Marshall-Hallenbeck

If they're considered "unstable" yeah, probably not a good idea to use them. Path is the new way to use files with Python, so we should move to that.

Hmm okay maybe then it is worth to enable some of them. Haven't seen Path yet, but perhaps it's the way to go

NeffIsBack avatar Apr 03 '25 17:04 NeffIsBack

We should probably use PTH then as well. However, that would be a lot to do :D

image

NeffIsBack avatar Apr 03 '25 17:04 NeffIsBack

Let the test run, everything good so far except the pso module, but that hangs in main as well: image

NeffIsBack avatar May 25 '25 19:05 NeffIsBack