me_cleaner icon indicating copy to clipboard operation
me_cleaner copied to clipboard

Add modules whitelist

Open c0d3z3r0 opened this issue 7 years ago • 4 comments

c0d3z3r0 avatar Jan 24 '18 09:01 c0d3z3r0

Thanks for this PR. Just a couple of things:

  • this breaks backwards compatibility, as now -k can't be used alone anymore. You can add nargs="?", default="" to parser.add_argument to have
    • a string if the list of the modules has been passed
    • an empty string (the default) if nothing has been passed
    • None if -k has been specified, but no list has been provided Now you can just replace if keep_modules == "all": with if keep_modules == None:.
  • I think it's better if we pass a list of strings (or None for "all modules") to the two check_and_remove_modules functions, instead of a comma-separated string. Move and adapt this part before calling check_and_remove_modules
  • break the lines if they are more than 80 characters

corna avatar Jan 29 '18 08:01 corna

"None if -k has been specified, but no list has been provided" -> Nope ;-) This is the one thing I needed sooo many times... but that does not work since argparse cannot know if the last argument after -k is -k's or file's value.

I found a way to solve this but that is very ugly. -k, nargs="?", default="" works for these invocations: ./me_cleaner.py -k touch_fw image.bin ./me_cleaner.py -k -- image.bin ./me_cleaner.py image.bin -k but not for ./me_cleaner.py -k image.bin for the reason stated above.

I think this is very, very ugly so my idea would be keeping -k as backward compatibly parameter and add two new parameters -W,--module-whitelist and -B, --module-blacklist or maybe -R (remove) and -K (keep). This way one can specify -k to keep all modules or one of -W, -B (-R, -K). @corna What do you like better?

c0d3z3r0 avatar Jan 29 '18 08:01 c0d3z3r0

@corna any progress here? is there anything I can do?

c0d3z3r0 avatar Mar 16 '18 21:03 c0d3z3r0

Thank you, I'll also take a closer look at this!

--

Note: I am currently working on a new tool with clear data structures and parsing separated from logic, so I'm checking the PRs here to see what else I can integrate; see https://github.com/platform-system-interface/intel_fw

orangecms avatar Oct 11 '25 16:10 orangecms