Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
3. Điều chỉnh giới hạn
Chính sách hộp cát ngăn Sandboxee gọi các syscall cụ thể, do đó, giảm bề mặt tấn công. Tuy nhiên, kẻ tấn công vẫn có thể gây ra các hiệu ứng không mong muốn bằng cách chạy một quy trình vô thời hạn hoặc làm cạn kiệt RAM và các tài nguyên khác.
Để giải quyết mối đe doạ này, Sandboxee chạy trong giới hạn thực thi chặt chẽ theo mặc định. Nếu các giới hạn mặc định này gây ra vấn đề cho quá trình thực thi hợp lệ của chương trình, bạn có thể điều chỉnh các giới hạn này bằng cách sử dụng lớp sandbox2::Limits
bằng cách gọi limits()
trên đối tượng trình thực thi.
Đoạn mã dưới đây cho thấy một số ví dụ về việc điều chỉnh hạn mức. Tất cả các tuỳ chọn có sẵn đều được nêu trong tệp tiêu đề limits.h.
// Restrict the address space size of the sandboxee to 4 GiB.
executor->limits()->set_rlimit_as(4ULL << 30);
// Kill sandboxee with SIGXFSZ if it writes more than 1 GiB to the filesystem.
executor->limits()->set_rlimit_fsize(1ULL << 30);
// Number of file descriptors which can be used by the sandboxee.
executor->limits()->set_rlimit_nofile(1ULL << 10);
// The sandboxee is not allowed to create core files.
executor->limits()->set_rlimit_core(0);
// Maximum 300s of real CPU time.
executor->limits()->set_rlimit_cpu(300);
// Maximum 120s of wall time.
executor->limits()->set_walltime_limit(absl::Seconds(120));
Để biết ví dụ về cách sử dụng lớp sandbox2::Limits
, hãy xem công cụ ví dụ.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2023-12-06 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2023-12-06 UTC."],[[["Sandboxee execution is restricted by default to minimize potential harm from malicious code."],["Sandbox2 provides the `Limits` class to adjust resource limits like address space size, file size, and CPU time, allowing customization for specific program needs."],["Developers can fine-tune resource constraints using methods like `set_rlimit_as` or `set_rlimit_cpu` for more control over the Sandboxee's behavior."],["Refer to the `limits.h` header file for detailed documentation on all available limit options and their functionalities."]]],[]]