mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
use AddDirectoryAt instead of AddDirectory in the security policy. Move the .gitmodules file to the lodepng folder (works this time)
This commit is contained in:
parent
27fcf0eb02
commit
53e4603b02
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "oss-internship-2020/sapi_lodepng/lodepng"]
|
||||
path = oss-internship-2020/sapi_lodepng/lodepng
|
||||
url = https://github.com/andreimedar/lodepng
|
|
@ -18,6 +18,7 @@
|
|||
#include <cassert>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
// #include <libgen.h>
|
||||
|
||||
#include "lodepng/lodepng.h"
|
||||
|
||||
|
@ -250,7 +251,8 @@ void generate_two_steps(const std::string &images_path) {
|
|||
int main(int argc, char *argv[]) {
|
||||
std::string images_path = std::filesystem::current_path().string();
|
||||
|
||||
std::cout << "flag = " << images_path << std::endl;
|
||||
std::cout << "path = " << images_path << std::endl;
|
||||
// std::cout << "dirname = " << dirname((char*)images_path.c_str()) << std::endl;
|
||||
|
||||
generate_one_step(images_path);
|
||||
generate_two_steps(images_path);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -206,8 +207,7 @@ ABSL_FLAG(string, images_path, std::filesystem::current_path().string(),
|
|||
// }
|
||||
// }
|
||||
|
||||
void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api,
|
||||
const std::string &images_path) {
|
||||
void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api) {
|
||||
unsigned int width = 512, height = 512;
|
||||
unsigned char *image = (unsigned char *)malloc(width * height * 4);
|
||||
assert(image);
|
||||
|
@ -224,7 +224,7 @@ void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api,
|
|||
// encode the image
|
||||
sapi::v::Array<unsigned char> sapi_image(image, width * height * 4);
|
||||
sapi::v::UInt sapi_width(width), sapi_height(height);
|
||||
std::string filename = images_path + "/out_generated1.png";
|
||||
std::string filename = "/output/out_generated1.png";
|
||||
sapi::v::ConstCStr sapi_filename(filename.c_str());
|
||||
|
||||
sapi::StatusOr<unsigned int> result = api.lodepng_encode32_file(
|
||||
|
@ -273,8 +273,7 @@ void generate_one_step(SapiLodepngSandbox &sandbox, LodepngApi &api,
|
|||
free(image);
|
||||
}
|
||||
|
||||
void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api,
|
||||
const std::string &images_path) {
|
||||
void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api) {
|
||||
// generate the values
|
||||
unsigned int width = 512, height = 512;
|
||||
unsigned char *image = (unsigned char *)malloc(width * height * 4);
|
||||
|
@ -293,7 +292,7 @@ void generate_two_steps(SapiLodepngSandbox &sandbox, LodepngApi &api,
|
|||
// encode the image into memory first
|
||||
sapi::v::Array<unsigned char> sapi_image(image, width * height * 4);
|
||||
sapi::v::UInt sapi_width(width), sapi_height(height);
|
||||
std::string filename = images_path + "/out_generated2.png";
|
||||
std::string filename = "/output/out_generated2.png";
|
||||
sapi::v::ConstCStr sapi_filename(filename.c_str());
|
||||
|
||||
sapi::v::ULLong sapi_pngsize;
|
||||
|
@ -390,7 +389,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
std::string images_path(absl::GetFlag(FLAGS_images_path));
|
||||
|
||||
std::cout << "flag = " << images_path << std::endl;
|
||||
std::cout << "path = " << images_path << std::endl;
|
||||
|
||||
SapiLodepngSandbox sandbox(images_path);
|
||||
ret = sandbox.Init();
|
||||
|
@ -402,8 +401,8 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
LodepngApi api(&sandbox);
|
||||
|
||||
generate_one_step(sandbox, api, images_path);
|
||||
generate_two_steps(sandbox, api, images_path);
|
||||
generate_one_step(sandbox, api);
|
||||
generate_two_steps(sandbox, api);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -58,7 +58,7 @@ TEST(generate_image, encode_decode_compare_one_step) {
|
|||
// encode the image
|
||||
sapi::v::Array<unsigned char> sapi_image(image, width * height * 4);
|
||||
sapi::v::UInt sapi_width(width), sapi_height(height);
|
||||
std::string filename = images_path + "/out_generated1.png";
|
||||
std::string filename = "/output/out_generated1.png";
|
||||
sapi::v::ConstCStr sapi_filename(filename.c_str());
|
||||
|
||||
sapi::StatusOr<unsigned int> result = api.lodepng_encode32_file(
|
||||
|
@ -134,7 +134,7 @@ TEST(generate_image, encode_decode_compare_two_step) {
|
|||
// encode the image into memory first
|
||||
sapi::v::Array<unsigned char> sapi_image(image, width * height * 4);
|
||||
sapi::v::UInt sapi_width(width), sapi_height(height);
|
||||
std::string filename = images_path + "/out_generated2.png";
|
||||
std::string filename = "/output/out_generated2.png";
|
||||
sapi::v::ConstCStr sapi_filename(filename.c_str());
|
||||
|
||||
sapi::v::ULLong sapi_pngsize;
|
||||
|
|
|
@ -40,10 +40,7 @@ class SapiLodepngSandbox : public LodepngSandbox {
|
|||
.AllowSystemMalloc()
|
||||
.AllowExit()
|
||||
.AllowStat()
|
||||
// .AddFile("/usr/local/google/home/amedar/sapi_lodepng/test_images/test1.png")
|
||||
.AddDirectory(images_path_, /*is_ro=*/false)
|
||||
// .AddDirectory("/usr/local/google/home/amedar/sapi_lodepng/test_images/out",
|
||||
// /*is_ro=*/false)
|
||||
.AddDirectoryAt(images_path_, "/output/", /*is_ro=*/false)
|
||||
.AllowSyscalls({
|
||||
__NR_futex,
|
||||
__NR_lseek,
|
||||
|
|
Loading…
Reference in New Issue
Block a user