OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
PathSafety.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include "utils_export.h"
5
6namespace Utils
7{
8 // Security-audit F001/F002/F003: one shared vocabulary for what an untrusted
9 // name may look like before it is joined onto a trusted directory. Every
10 // join of archive-, upload-, or ODB++-derived text onto a filesystem path
11 // must pass one of these checks first. The checks REJECT; they never
12 // transform - a rejected name is a hostile or malformed input, not
13 // something to launder into a safe form.
14
15 // A single, flat filename component (no directory structure at all):
16 // no separators, no traversal, no rooted/drive forms, no control
17 // characters, no trailing dots/spaces (Windows name normalization),
18 // and a sane length. Use for uploaded file names and other names that
19 // become exactly one path component.
20 bool is_safe_filename_component(const std::string& name);
21
22 // A relative archive-entry-style path ("step/layers/features.Z" is fine):
23 // non-empty, not rooted, no drive form, no control characters, and no
24 // empty/dot/dot-dot component after splitting on '/' or '\'. Interior
25 // separators are legal; escaping the base directory is not. Use for
26 // archive entry names and ODB++-derived nested member names.
27 bool is_safe_relative_entry_path(const std::string& name);
28}
bool is_safe_filename_component(const std::string &name)
bool is_safe_relative_entry_path(const std::string &name)