|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Validates derived variable definitions, one row per rule. More...
Go to the source code of this file.
Reads a table of derived variable definitions and writes one row per definition that breaks a rule, with the reason in REASON. Nothing is executed, no view is built and no target table is needed: the macro is a scan of definitions, so it can run at submit time - or against any table of expressions in a code scanning tool - long before the definitions are used.
The input is the shape a control table carries, which is the shape mddl_derivedvars.sas creates:
Extra columns are ignored, so a caller can scan the control table itself, a staged submission, or a table of expressions assembled from a program.
VAR_LOGIC is concatenated into a generated assignment, so an expression that can submit a program of its own (DOSUBL) or reach the file system, the environment or the macro symbol table is a way into the session. Blocked characters cannot cover that: BYTE(59) builds the semicolon at run time, so a payload carries no blocked character in its source text - while the name of the function it calls is part of the expression this scan reads, and cannot be constructed. Quoted literals are removed before the check, so a refused word that is only data is not read as a call.
The refused names are DOSUBL, JAVAOBJ, JAVAMETA, SYMGET, SYMPUT, SYMPUTX, SYSGET, GETOPTION, PATHNAME, FILEEXIST, FOPEN, FREAD, FGET, FCLOSE, DOPEN, DREAD, DNUM, MOPEN, SLEEP, FILENAME, FDELETE, FCOPY, DCREATE and DLCREATE. Add your own with denyfuncs=.
| [in] | inds= | The definitions to check |
| [out] | outds= | (work.dv_check) One row per definition that breaks a rule: NAME (the upcased VAR_NM) and REASON. Empty when every row is valid |
| [in] | physlist= | (0) Space separated list of the columns of the target table, unquoted and case insensitive - what mf_getvarlist(&libds) returns. Supplied, a VAR_NM that collides with one of them is refused; when the target is not at hand, leave it at 0 and that rule is not applied |
| [in] | reserved= | (0) Space separated list of names that may not be used |
| [in] | denyfuncs= | (0) Space separated list of further function names to refuse, for a site that allows more of the SAS vocabulary than the default. Each entry must be a function name - letters, digits and underscores - so the pattern the check builds stays a pattern of names |
Definition in file mp_derivedvarcheck.sas.