Loading...
Searching...
No Matches
getcolvals.test.4.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing getcolvals service - input validation (security)
4 @details The libds and col in the IWANT input table must be
5 well-formed (LIBREF.DATASET and SAS name). An invalid value aborts
6 the service, which shows up as a canceled child job (an aborted
7 service registers no webout).
8
9 The payloads in tests 1-2 resolve to a REAL table / column when the
10 request content is executed as macro code, so on a vulnerable
11 service the job completes, and only the validating service cancels
12 it - the assertion cannot pass against a service that does not
13 validate.
14
15 <h4> SAS Macros </h4>
16 @li mpe_assert_abort.sas
17 @li mp_assert.sas
18 @li mpe_execute.sas
19 @li mf_getuniquefileref.sas
20
21**/
22
23%let _program=&appLoc/services/public/getcolvals;
24
25/**
26 * Test 1 - macro content in libds must abort the service
27 */
28%let f1=%mf_getuniquefileref();
29data _null_;
30 file &f1 termstr=crlf;
31 put 'LIBDS:$100. COL:$100.';
32 put '%sysfunc(coalescec(&dclib..MPE_X_TEST,)),SOME_TIME';
33run;
34
35%mpe_execute(&_program,
36 viyacontext=&defaultcontext,
37 inputfiles=&f1:iwant,
38 outref=web1,
39 outstatus=work.ab1,
40 failfast=0,
41 viyaresult=WEBOUT_TXT
42)
43
44%mpe_assert_abort(
45 desc=Macro content in libds aborts the service,
46 outstatus=work.ab1,
47 msg=Invalid libds
48)
49
50/**
51 * Test 2 - macro content in col must abort the service
52 */
53%let f2=%mf_getuniquefileref();
54data _null_;
55 file &f2 termstr=crlf;
56 put 'LIBDS:$100. COL:$100.';
57 put "&dclib..MPE_X_TEST,%nrstr(%sysfunc(coalescec(SOME_TIME,)))";
58run;
59
60%mpe_execute(&_program,
61 viyacontext=&defaultcontext,
62 inputfiles=&f2:iwant,
63 outref=web2,
64 outstatus=work.ab2,
65 failfast=0,
66 viyaresult=WEBOUT_TXT
67)
68
69%mpe_assert_abort(
70 desc=Macro content in col aborts the service,
71 outstatus=work.ab2,
72 msg=Invalid col
73)
74
75/**
76 * Test 3 - valid inputs still return values
77 */
78%let f3=%mf_getuniquefileref();
79data _null_;
80 file &f3 termstr=crlf;
81 put 'LIBDS:$100. COL:$100.';
82 put "&dclib..MPE_X_TEST,SOME_TIME";
83run;
84
85%mpe_execute(&_program,
86 viyacontext=&defaultcontext,
87 inputfiles=&f3:iwant,
88 outlib=web3
89)
90
91%let nobs=0;
92proc sql noprint;
93select count(*) into: nobs from web3.vals;
94quit;
95
96%mp_assert(
97 iftrue=(&nobs>0),
98 desc=Valid inputs return values,
99 outds=work.test_results
100)
101
102/**
103 * dump results to the log for offline inspection
104 */
105data _null_;
106 set work.test_results;
107 putlog 'TEST_RESULT_LINE: ' test_result ' - ' test_description;
108run;