Loading...
Searching...
No Matches
validatefilter.test.1.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing validatefilter service - input validation (security)
4 @details The filter_table in the IWANT input table must be a
5 well-formed LIBREF.DATASET. An invalid value aborts the service
6 before it reaches mp_filterstore. The abort shows up as a canceled
7 child job (an aborted service registers no webout).
8
9 The payload in test 1 resolves to a REAL table when the request
10 content is executed as macro code, so on a vulnerable service the
11 job completes, and only the validating service cancels it - the
12 assertion cannot pass against a service that does not validate.
13
14 <h4> SAS Macros </h4>
15 @li mp_assert.sas
16 @li mx_execute.sas
17 @li mf_getuniquefileref.sas
18
19**/
20
21%let _program=&appLoc/services/public/validatefilter;
22
23/**
24 * Test 1 - macro content in filter_table must abort the service
25 */
26%let f1=%mf_getuniquefileref();
27data _null_;
28 file &f1 termstr=crlf;
29 put 'FILTER_TABLE:$41.';
30 put '%sysfunc(coalescec(&dclib..MPE_TABLES,))';
31run;
32
33%mx_execute(&_program,
34 viyacontext=&defaultcontext,
35 inputfiles=&f1:iwant,
36 outref=web1,
37 viyaresult=WEBOUT_TXT
38)
39
40%let abort1=0;
41data _null_;
42 set work.results;
43 if state='canceled' then call symputx('abort1',1);
44run;
45
46%mp_assert(
47 iftrue=(&abort1=1),
48 desc=Macro content in filter_table aborts the service,
49 outds=work.test_results
50)
51
52/**
53 * Test 2 - valid filter_table still stores a filter
54 */
55%let f2=%mf_getuniquefileref();
56data _null_;
57 file &f2 termstr=crlf;
58 put 'FILTER_TABLE:$41.';
59 put "&dclib..MPE_TABLES";
60run;
61%let f3=%mf_getuniquefileref();
62data _null_;
63 file &f3 termstr=crlf;
64 infile datalines4 dsd;
65 input;
66 put _infile_;
67datalines4;
68GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32. OPERATOR_NM:$10. RAW_VALUE:$4000.
69AND,AND,1,LIBREF,CONTAINS,"'DC'"
70AND,OR,2,DSN,=,"'MPE_LOCK_ANYTABLE'"
71;;;;
72run;
73
74%mx_execute(&_program,
75 viyacontext=&defaultcontext,
76 inputfiles=&f2:iwant &f3:filterquery,
77 outlib=web2
78)
79
80%let nobs=0;
81proc sql noprint;
82select count(*) into: nobs from web2.result;
83quit;
84
85%mp_assert(
86 iftrue=(&nobs>0),
87 desc=Valid filter_table returns a filter result,
88 outds=work.test_results
89)
90
91/**
92 * dump results to the log for offline inspection
93 */
94data _null_;
95 set work.test_results;
96 putlog 'TEST_RESULT_LINE: ' test_result ' - ' test_description;
97run;