apidoc::sanitize_path (private)

 apidoc::sanitize_path [ -prefix prefix ] path

Defined in packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl

Return a sanitized path. Cleans path from directory traversal attacks and checks, if someone tries to access content outside of the specified prefix.

Switches:
-prefix (optional, defaults to "packages")
Parameters:
path (required)
Returns:
sanitized path

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-api-browser/www/content-page-view.tcl packages/acs-api-browser/ www/content-page-view.tcl apidoc::sanitize_path apidoc::sanitize_path packages/acs-api-browser/www/content-page-view.tcl->apidoc::sanitize_path packages/acs-api-browser/www/procs-file-view.tcl packages/acs-api-browser/ www/procs-file-view.tcl packages/acs-api-browser/www/procs-file-view.tcl->apidoc::sanitize_path ad_conn ad_conn (public) apidoc::sanitize_path->ad_conn

Testcases:
No testcase defined.
Source code:
        set path [ns_normalizepath $path]
        if {![string match "/$prefix/*" $path]} {
            set filename "$::acs::rootdir/$path"
            ns_log notice [subst {INTRUDER ALERT:\n\nsomesone tried to snarf '$filename'!
                file exists: [file exists $filename] user_id: [ad_conn user_id] peer: [ad_conn peeraddr]
            }]

            set path $prefix/$path
        }

        return $path
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: