-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolicy.cpp
More file actions
27 lines (21 loc) · 922 Bytes
/
Copy pathPolicy.cpp
File metadata and controls
27 lines (21 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//===-- Policy.cpp - Security policy -----------------------------*- C++ -*-===//
//
// Part of the ZBC semihosting monorepo. MIT licensed (see LICENSE).
//
//===----------------------------------------------------------------------===//
#include "zbc/Policy.h"
namespace zbc {
SandboxedPolicy::SandboxedPolicy(std::string_view SandboxDir) {
PathValidatorConfig Config;
Config.SandboxDir = std::string(SandboxDir);
Validator = std::make_unique<PathValidator>(std::move(Config));
}
Result<std::string> SandboxedPolicy::resolvePath(std::string_view Path,
bool ForWrite,
bool FollowLeafSymlink) {
return Validator->validate(Path, ForWrite, FollowLeafSymlink);
}
void SandboxedPolicy::addAllowedPath(std::string_view Prefix, bool AllowWrite) {
Validator->addAllowedPath(Prefix, AllowWrite);
}
} // namespace zbc