ctc-oss / fapolicy-analyzer

Tools to assist with the configuration and management of fapolicyd.
https://ctc-oss.github.io/fapolicy-analyzer
GNU General Public License v3.0
13 stars 5 forks source link

Improved profiler env validation #717

Closed tparchambault closed 1 year ago

tparchambault commented 1 year ago

Validation of Profiler's environment variable field added such that errors are presented in a manner consistent with the current profiler args validation. Variable names are also verified that they do not start with a number and can contain only [a-zA-Z0-6_] chararters.

Closes #644

tparchambault commented 1 year ago

PR specific unit-tests still need to be generated.

tparchambault commented 1 year ago

The env var string is expected to be a number of K=V pairs, separated by commas. A single leading double quote and a single trailing double quote will be ignored. Internal double quotes and whitespace will be untouched.

From https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names , supported env var names are verified to support the following convention:

Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit.

We can revisit supported env var names upon request. Values are not checked consequently any string is acceptable provided they don't contain commas or equal signs.

tparchambault commented 1 year ago

New app code verifies:

  1. Environment string is a comma separated list of K=V pairs
  2. K is not missing, e.g. "-V" nor is empty.
  3. K is comprised of only upper or lower case letters, numbers, and underscores. K can not start with a number.
  4. Single leading or trailing double quotes are stripped off of V
tparchambault commented 1 year ago

Tested rpm install over a RHEL 8.6 platform. No issues observed.