is_safe_compiler_arg#

scikitplot.cython.is_safe_compiler_arg(arg, *, allow_shell_meta=False, allow_dangerous=False)[source]#

Return True when a compiler argument string is safe to pass.

Parameters:
argstr

A single compiler flag (e.g., "-O2", "-DNDEBUG").

allow_shell_metabool, default=False

If False, shell metacharacters are rejected.

allow_dangerousbool, default=False

If False, known-dangerous flag patterns are rejected.

Returns:
bool

True if the argument passes all checks, False otherwise.

Parameters:
  • arg (str)

  • allow_shell_meta (bool)

  • allow_dangerous (bool)

Return type:

bool

Notes

Null bytes are always rejected regardless of other flags.

Examples

>>> is_safe_compiler_arg("-O2")
True
>>> is_safe_compiler_arg("-O2; rm -rf /")
False
>>> is_safe_compiler_arg("-imacros /etc/shadow")
False