xref: /aosp_15_r20/external/sandboxed-api/contrib/woff2/woff2_sapi.h (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CONTRIB_WOFF2_WOFF2_SAPI_H_
16 #define CONTRIB_WOFF2_WOFF2_SAPI_H_
17 
18 #include <syscall.h>
19 
20 #include <cstdlib>
21 
22 #include "woff2_sapi.sapi.h"  // NOLINT(build/include)
23 
24 namespace sapi_woff2 {
25 
26 class Woff2SapiSandbox : public WOFF2Sandbox {
27  public:
ModifyPolicy(sandbox2::PolicyBuilder *)28   std::unique_ptr<sandbox2::Policy> ModifyPolicy(
29       sandbox2::PolicyBuilder*) override {
30     return sandbox2::PolicyBuilder()
31         .AllowDynamicStartup()
32         .AllowSystemMalloc()
33         .AllowRead()
34         .AllowStat()
35         .AllowWrite()
36         .AllowExit()
37         .AllowSyscalls({
38             __NR_futex,
39             __NR_close,
40             __NR_lseek,
41             __NR_getpid,
42             __NR_clock_gettime,
43             __NR_madvise,
44         })
45         .BuildOrDie();
46   }
47 };
48 
49 }  // namespace sapi_woff2
50 
51 #endif  // CONTRIB_WOFF2_WOFF2_SAPI_H_
52