Files
dc/sas/sasjs/services/auditors/getdiffs.sas
T
dc 4f43221819
Build / Build-and-ng-test (pull_request) Successful in 6m3s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m59s
Build / Build-and-test-development (pull_request) Successful in 25m32s
chore: rename test log marker, declare all called macros in headers
- the test result putlog marker is TEST_RESULT_LINE, not a review-session
  specific name
- declare mf_getuser.sas in refreshlibs, refreshcatalog, getdiffs and
  dirlist (called by the new admin gates; was only resolved transitively
  through mpe_getgroups) and mp_abort.sas in validatefilter
2026-09-21 19:24:20 +00:00

103 lines
2.8 KiB
SAS

/**
@file getdiffs.sas
@brief Retrieves the diff file for viewing
@details
<h4> SAS Macros </h4>
@li mpe_getvars.sas
@li mpe_accesscheck.sas
@li mf_getattrn.sas
@li mf_getuser.sas
@li mp_abort.sas
@li mp_binarycopy.sas
@li mp_streamfile.sas
@li mp_validatecol.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.
**/
%mpeinit()
%mpe_getvars(BrowserParams, BrowserParams);
/**
* Validate inputs before they reach executable code. libds is passed to
* the access check (which interpolates it into SQL) and table is used in
* the staging file path, so both must be well formed before use. Values
* are re-read with symget (never re-resolved) and validated in a data
* step so no macro content in the request can execute.
*/
%let is_libds=0;
%let is_table=0;
%let is_csv=0;
data _null_;
length _libds $64 _table $64 _csv $128;
_libds=symget('libds');
_table=symget('table');
_csv=coalescec(symget('stp_diffs_csv'),'tempDiffs.csv');
%mp_validatecol(_libds,LIBDS,is_libds)
%mp_validatecol(_table,ISNAME,is_table)
/* the diffs csv filename must stay inside the staging directory */
if findc(_csv,'/\')>0 or index(_csv,'..')>0 then do;
is_csv=0;
putlog 'ERR' 'OR: Invalid stp_diffs_csv:' _csv;
end;
else is_csv=1;
if is_libds=0 then putlog 'ERR' 'OR: Invalid libds:' _libds;
if is_table=0 then putlog 'ERR' 'OR: Invalid table:' _table;
call symputx('is_libds',is_libds,'l');
call symputx('is_table',is_table,'l');
call symputx('is_csv',is_csv,'l');
if is_libds=1 then call symputx('libds',_libds,'g');
if is_table=1 then call symputx('table',_table,'g');
if is_csv=1 then call symputx('stp_diffs_csv',_csv,'g');
run;
%mp_abort(iftrue= (&is_libds ne 1)
,mac=&_program..sas
,msg=%str(Invalid libds)
)
%mp_abort(iftrue= (&is_table ne 1)
,mac=&_program..sas
,msg=%str(Invalid table)
)
%mp_abort(iftrue= (&is_csv ne 1)
,mac=&_program..sas
,msg=%str(Invalid stp_diffs_csv)
)
/* security checks */
%let user=%mf_getuser();
%mpe_accesscheck(&libds,outds=authEDIT,user=&user,access_level=EDIT)
%mpe_accesscheck(&libds,outds=authAPP,user=&user,access_level=APPROVE)
%macro mpestp_diffs();
%if %mf_getattrn(work.authEDIT,NLOBS)=0 & %mf_getattrn(work.authAPP,NLOBS)=0
%then %do;
%mp_abort(msg=%str(
&user not authorised to download diffs data for &stp_table)
,mac=mpestp_diffs.sas);
%return;
%end;
%mp_abort(iftrue= (&syscc ne 0)
,mac=&_program..sas
,msg=%str(syscc=&syscc)
)
/* stream diffs csv to client */
%mp_streamfile(contenttype=EXCEL
,inloc=%str(&mpelocapprovals/&TABLE/&STP_DIFFS_CSV)
,outname=&STP_DIFFS_CSV
)
%mend mpestp_diffs;
%mpestp_diffs()
%mpeterm()