Files
dc/sas/sasjs/macros/mpe_validatecol.sas
T
dc 0fa5da8abf
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m53s
Build / Build-and-test-development (pull_request) Successful in 25m7s
fix(security): accept the format-catalog form when validating a libds
mpe_accesscheck and validatefilter validated their libds input with
mp_validatecol(LIBDS), which rejects the LIBREF.CATALOGNAME-FC form that
Data Controller uses to address a format catalog.  A format-catalog load
or filter therefore aborted with "Invalid base_table" / "Invalid
filter_table" - stagedata, getdata and postdata all reach mpe_accesscheck
through the edit/approve path.

Add mpe_validatecol, a wrapper that permits the catalog form: the -FC
suffix is matched exactly and the remainder is validated as a strict
LIBREF.DATASET, so the whole value is covered and a caller that needs the
catalog reference downstream (MPE_SECURITY stores it with the suffix)
still receives it.  getrawdata and getcolvals had grown an inline version
of this check that scanned on the dash and validated only the prefix,
leaving whatever followed it unvalidated; the wrapper replaces both.

mpe_validatecol.test.sas asserts the matrix - plain libds, catalog form,
and payloads that smuggle content past a valid libds prefix.
2026-09-22 11:23:37 +00:00

48 lines
1.7 KiB
SAS

/**
@file
@brief Validates a column of values, including the Data Controller
format-catalog form of a libds reference
@details Wrapper around mp_validatecol() that adds the Data Controller
convention of addressing a format catalog as `LIBREF.CATALOGNAME-FC`
to the LIBDS rule.
The `-FC` suffix is matched exactly and the remainder is validated as
a strict LIBREF.DATASET, so the *whole* value is covered by the
validation - a bare scan on the dash would leave anything after it
unvalidated. The input column itself is never modified, so a caller
that needs the catalog reference downstream (to match MPE_SECURITY,
for instance) still receives it.
@param [in] incol Input column (a data step variable)
@param [in] rule Validation rule, as per mp_validatecol()
@param [out] outcol 1 when the value is valid, else 0
<h4> SAS Macros </h4>
@li mp_validatecol.sas
@li mf_getuniquename.sas
@version 9.2
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
and may not be re-distributed or re-sold without the express permission of
4GL Apps Ltd.
**/
%macro mpe_validatecol(incol,rule,outcol);
%if &rule=LIBDS %then %do;
/* tempcol is given a unique name with every invocation */
%local tempcol;
%let tempcol=%mf_getuniquename(prefix=cat);
&tempcol=strip(&incol);
/* permit the format-catalog form: LIBREF.CATALOGNAME-FC, exactly */
if length(&tempcol)>3
and upcase(substr(&tempcol,length(&tempcol)-2,3))='-FC'
then &tempcol=substr(&tempcol,1,length(&tempcol)-3);
%mp_validatecol(&tempcol,LIBDS,&outcol)
drop &tempcol;
%end;
%else %mp_validatecol(&incol,&rule,&outcol);
%mend mpe_validatecol;