Ignore:
Timestamp:
2014-03-13T14:34:48+13:00 (10 years ago)
Author:
ak19
Message:

First security commit. 1. Introducing the new securitools.h and .cpp files, which port the functions necessary to implement security in Greenstone from OWASP-ESAPI for Java, since OWASP's C++ version is largely not yet implemented, even though their code compiles. The newly added runtime-src/packages/security which contains OWASP ESAPI for C++ will therefore be removed again shortly. 2. receptionist.cpp now sets various web-encoded variants for each cgiarg macro, such as HTML entity encoded, attr encoded, javascript encoded (and css encoded variants). These are now used in the macro files based on which variant is suited to the context. 3. This commit further contains the minimum changes to protect the c, d, and p cgi variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/macros/document.dm

    r28497 r28888  
    3535_tocclose_ {</div>}
    3636
    37 _nextsearchresult_ {_If_("_cgiargsrn_" ne "0",<li id="nextresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrn_">_textnextsearchresult_</a></li>)}
    38 
    39 _prevsearchresult_ {_If_("_cgiargsrp_" ne "0",<li id="prevresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrp_">_textprevsearchresult_</a></li>)}
     37_nextsearchresult_ {_If_("_cgiargsrn_" ne "0",<li id="nextresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrnUrlsafe_">_textnextsearchresult_</a></li>)}
     38
     39_prevsearchresult_ {_If_("_cgiargsrp_" ne "0",<li id="prevresult"><a href="_httpquery_&amp;ifl=1&amp;ifln=_cgiargsrpUrlsafe_">_textprevsearchresult_</a></li>)}
    4040
    4141_content_ {
     
    142142}
    143143
    144 _doc-url_ {_gwcgi_?e=_compressedoptions_&amp;a=_cgiarga_&amp;c=_cgiargc_&amp;cl=_cgiargcl_&amp;d=_cgiargd_}
     144_docurl_ {_gwcgi_?e=_compressedoptions_&amp;a=_cgiargaUrlsafe_&amp;c=_cgiargcUrlsafe_&amp;cl=_cgiargclUrlsafe_&amp;d=_cgiargdUrlsafe_}
    145145
    146146_loginlink_ {
    147 <div id="usercommentlink"><a href="_doc-url_&amp;uan=1">_textaddusercomment_</a></div>
     147<div id="usercommentlink"><a href="_docurl_&amp;uan=1">_textaddusercomment_</a></div>
    148148}
    149149
     
    155155<form name="AddUserCommentForm" id="usercommentform">
    156156<!--<p>_textcommentusername_ <input type="text" name="username"></p>-->
    157 <input type=hidden name="username" value="_cgiargun_">
     157<input type=hidden name="username" value="_cgiargunAttrsafe_">
    158158<p>
    159159_textaddusercomment_
    160160<textarea name="comment" rows="10" cols="70"></textarea>
    161 <input type=hidden name="d" value="_cgiargd_">
     161<input type=hidden name="d" value="_cgiargdAttrsafe_">
    162162</p>
    163163
     
    165165<label id="usercommentfeedback"></label>
    166166
    167 <div id="usercommentlogoutlink"><a href="_doc-url_&amp;un=">_textusercommentlogout_</a></div>
     167<div id="usercommentlogoutlink"><a href="_docurl_&amp;un=">_textusercommentlogout_</a></div>
    168168</form>
    169169
     
    297297<form name="GotoForm" method="get" action="_gwcgi_">
    298298<input type=hidden name="e" value="_decodedcompressedoptions_">
    299 <input type=hidden name="d" value="_cgiargd_">
    300 <input type=hidden name="cl" value="_cgiargcl_">
     299<input type=hidden name="d" value="_cgiargdAttrsafe_">
     300<input type=hidden name="cl" value="_cgiargclAttrsafe_">
    301301<input type="text" name="gp" size="3" maxlength="4">
    302302<input type="submit" value="_textgoto_">
     
    322322  <PARAM NAME=library      VALUE="_gwcgi_?e=_compressedoptions_">
    323323  <PARAM NAME=phindcgi     VALUE="_gwcgi_?a=phind">
    324   <PARAM NAME=collection   VALUE="_cgiargc_">
     324  <PARAM NAME=collection   VALUE="_cgiargcAttrsafe_">
    325325  <PARAM NAME=classifier   VALUE="_phindnumber_">
    326326
     
    344344
    345345        <param name="gwcgi" value="_gwcgi_">
    346         <param name="collection" value="_cgiargc_">
    347         <param name="classifier" value="_cgiargcl_.1">
    348 
    349         <param name="hrefMustHave" value="cl=_cgiargcl_.1">
     346        <param name="collection" value="_cgiargcAttrsafe_">
     347        <param name="classifier" value="_cgiargclAttrsafe_.1">
     348
     349        <param name="hrefMustHave" value="cl=_cgiargclAttrsafe_.1">
    350350        <param name="imageMustNotHave" value="hl=\%x=\%gt=\%gc=\%.pr">
    351351
     
    495495
    496496
    497 _imagehighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=1&amp;gc=_cgiarggc_&amp;gt=_cgiarggt_,_textHIGHLIGHT_,_texticonhighlight_)}
    498 
    499 _imagenohighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=0&amp;gc=_cgiarggc_&amp;gt=_cgiarggt_,_document:textNOHIGHLIGHT_,_document:texticonnohighlight_)}
     497_imagehighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=1&amp;gc=_cgiarggcUrlsafe_&amp;gt=_cgiarggtUrlsafe_,_textHIGHLIGHT_,_texticonhighlight_)}
     498
     499_imagenohighlight_ {_docbutton_(_httpcurrentdocument_&amp;hl=0&amp;gc=_cgiarggcUrlsafe_&amp;gt=_cgiarggtUrlsafe_,_document:textNOHIGHLIGHT_,_document:texticonnohighlight_)}
    500500
    501501_imagecontracttoc_ {_docbutton_(_httpcurrentdocument_&amp;gc=0,_textCONTRACTCONTENTS_,_texticoncontracttoc_)}
     
    734734    ,
    735735    //if no metadata was passed as link\, then the GS version of the document will be used.
    736     a2a_config.linkurl = gsapi.fullDomainURL("_gwcgi_")+ "?c=_cgiargc_&a=d&d=_cgiargd_";
     736    // Use jssafe variants of the args in the following and then urlencode it from javascript
     737    // http://stackoverflow.com/questions/332872/how-to-encode-a-url-in-javascript
     738    // http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent
     739    //a2a_config.linkurl = gsapi.fullDomainURL("_gwcgi_")+ "?c=cgiargc&a=d&d=cgiargd";
     740    a2a_config.linkurl = gsapi.fullDomainURL("_gwcgi_")+ "?c=" + encodeURIComponent(_cgiargcJssafe_) + "&a=d&d=" + encodeURIComponent(_cgiargdJssafe_);
    737741)
    738742
Note: See TracChangeset for help on using the changeset viewer.