chalk icon indicating copy to clipboard operation
chalk copied to clipboard

feat: allow bypassing chalk via CHALK_BYPASS environment variable

Open ee7 opened this issue 2 years ago • 2 comments

Description

@nettrino and I had a good discussion earlier today about bypassing chalk (issue https://github.com/crashappsec/chalk/issues/224). Here's a sketch of a possible implementation.

This is the "avoid as much chalk as possible" flavor, optimizing for a completely independent, minimal code path.

It allows bypassing the exec command:

$ CHALK_BYPASS=1 chalk exec echo hi
chalk: the CHALK_BYPASS environment variable is set.
Running the following command without chalk:
  echo hi
hi

and bypassing the docker command:

$ CHALK_BYPASS=1 chalk docker --version
chalk: the CHALK_BYPASS environment variable is set.
Running the following command without chalk:
  docker --version
Docker version 25.0.3, build 4debf411d1

and errors when the command is not docker or exec:

$ CHALK_BYPASS=1 chalk version
error: CHALK_BYPASS was set, but the chalk command is not 'docker' or 'exec'. Quitting.

Refs: #224

Testing

Run commands like illustrated above.

To-do

If we wanted to continue in this direction:

  • [ ] Tests
  • [ ] Docs
  • [ ] Consider handling chalk being named docker

ee7 avatar Mar 01 '24 13:03 ee7

Per my last comment on the linked issue, I really don't think we should do this before the con4m refactor without a very good reason.

viega avatar Mar 01 '24 14:03 viega

+1. this approach I think breaks a bunch of semantics about chalk comment. if we need to bypass chalk, I think we need to do that in such a way which bypasses error-prone areas of chalk such as anything to do with user configs/reporting/etc without breaking user semantics

for example chalk exec needs to grab some potential exec args from either command line args or embedded config. saying that CHALK_BYPASS now breaks some chalk commands depending on context I dont think is acceptable.

a lot of con4m evaluation will be nop in v2 so over there we can correctly skip just the bits in chalk which can possible blow up such as chalk collection/reporting/etc.

miki725 avatar Mar 05 '24 04:03 miki725

closing as we wont be taking this approach in the long term and this just pollutes PRs list

miki725 avatar Jun 04 '24 15:06 miki725