-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
166 changed files
with
3,922 additions
and
2,788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Sandboxing | ||
|
||
Rune is capable of enforcing the following types of limitations: | ||
* Memory limiting, where you specify the maxium amount of memory that Rune may | ||
use either during compilation or execution. | ||
* Instruction budgeting, where you can specify how many instructions the virtual | ||
machine is permitted to execute. | ||
|
||
## Instruction budgeting | ||
|
||
Instruction budgeting is performed using the [`with` function] in the | ||
`rune::budget` module. | ||
|
||
The `with` function is capable of wrapping functions and futures. When wrapping | ||
a future it ensures that the budget is suspended appropriately with the | ||
execution of the future. | ||
|
||
Budgeting is only performed on a per-instruction basis in the virtual machine. | ||
What exactly constitutes an instruction might be a bit vague. But important to | ||
note is that without explicit co-operation from native functions the budget | ||
cannot be enforced. So care must be taken with the native functions that you | ||
provide to Rune to ensure that the limits you impose cannot be circumvented. | ||
|
||
[`with` function]: https://docs.rs/rune/latest/rune/runtime/budget/fn.with.html | ||
|
||
## Memory limiting | ||
|
||
Memory limiting is performed using the [`with` function] in the | ||
`rune::alloc::limit` module. | ||
|
||
```rust | ||
use rune::alloc::limit; | ||
use rune::alloc::Vec; | ||
|
||
let f = limit::with(1024, || { | ||
let mut vec = Vec::<u32>::try_with_capacity(256)?; | ||
|
||
for n in 0..256u32 { | ||
vec.try_push(n)?; | ||
} | ||
|
||
Ok::<_, rune_alloc::Error>(vec.into_iter().sum::<u32>()) | ||
}); | ||
|
||
let sum = f.call()?; | ||
assert_eq!(sum, 32640); | ||
``` | ||
|
||
In order for memory limiting to work as intended, you're may only use the | ||
collections provided in the [`rune::alloc`] module. These contain forks of | ||
popular collections such as [`std::collections`] and [`hashbrown`]. | ||
|
||
The `with` function is capable of wrapping [functions] and [futures]. When | ||
wrapping a future it ensures that the limit is suspended appropriately with the | ||
execution of the future. | ||
|
||
[`with` function]: https://docs.rs/rune/latest/rune/alloc/limit/fn.with.html | ||
[`rune::alloc`]: https://docs.rs/rune/latest/rune/alloc/index.html | ||
[`std::collections`]: https://doc.rust-lang.org/std/collections/index.html | ||
[`hashbrown`]: docs.rs/hashbrown | ||
[functions]: | ||
[futures]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<img alt="rune logo" src="https://raw.githubusercontent.com/rune-rs/rune/main/assets/icon.png" /> | ||
<br> | ||
<a href="https://rune-rs.github.io"><b>Visit the site 🌐</b></a> | ||
— | ||
<a href="https://rune-rs.github.io/book/"><b>Read the book 📖</b></a> | ||
|
||
# rune-alloc-macros | ||
|
||
<a href="https://github.com/rune-rs/rune"><img alt="github" src="https://img.shields.io/badge/github-rune--rs/rune-8da0cb?style=for-the-badge&logo=github" height="20"></a> | ||
<a href="https://crates.io/crates/rune-alloc-macros"><img alt="crates.io" src="https://img.shields.io/crates/v/rune-alloc-macros.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a> | ||
<a href="https://docs.rs/rune-alloc-macros"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rune--alloc--macros-66c2a5?style=for-the-badge&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20"></a> | ||
<a href="https://github.com/rune-rs/rune/actions?query=branch%3Amain"><img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rune-rs/rune/ci.yml?branch=main&style=for-the-badge" height="20"></a> | ||
<a href="https://discord.gg/v5AeNkT"><img alt="chat on discord" src="https://img.shields.io/discord/558644981137670144.svg?logo=discord&style=flat-square" height="20"></a> | ||
<br> | ||
<br> | ||
|
||
Macros for the Rune Language, an embeddable dynamic programming language for Rust. | ||
|
||
<br> | ||
|
||
## Usage | ||
|
||
This is part of the [Rune Language](https://rune-rs.github.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<img alt="rune logo" src="https://raw.githubusercontent.com/rune-rs/rune/main/assets/icon.png" /> | ||
<br> | ||
<a href="https://rune-rs.github.io"><b>Visit the site 🌐</b></a> | ||
— | ||
<a href="https://rune-rs.github.io/book/"><b>Read the book 📖</b></a> | ||
|
||
# rune-alloc | ||
|
||
<a href="https://github.com/rune-rs/rune"><img alt="github" src="https://img.shields.io/badge/github-rune--rs/rune-8da0cb?style=for-the-badge&logo=github" height="20"></a> | ||
<a href="https://crates.io/crates/rune-alloc"><img alt="crates.io" src="https://img.shields.io/crates/v/rune-alloc.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a> | ||
<a href="https://docs.rs/rune-alloc"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rune--alloc-66c2a5?style=for-the-badge&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20"></a> | ||
<a href="https://github.com/rune-rs/rune/actions?query=branch%3Amain"><img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rune-rs/rune/ci.yml?branch=main&style=for-the-badge" height="20"></a> | ||
<a href="https://discord.gg/v5AeNkT"><img alt="chat on discord" src="https://img.shields.io/discord/558644981137670144.svg?logo=discord&style=flat-square" height="20"></a> | ||
<br> | ||
<br> | ||
|
||
The Rune Language, an embeddable dynamic programming language for Rust. |
Oops, something went wrong.