Skip to content

Commit

Permalink
feat: add egui integration, use single struct for status
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederik Terstappen committed Apr 25, 2024
1 parent 702763a commit 770e914
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 120 deletions.
103 changes: 103 additions & 0 deletions .deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[graph]
# targets = [] # Disables all not explicitly listed targets
# exclude = [] # Also removes dependencies of package if not otherwise connected
all-features = true
no-default-features = false
# features = [] # We use all-features
exclude-dev = false

[output]
feature-depth = 1

[advisories]
version = 2
# db-path = "$CARGO_HOME/advisory-dbs"
# db-urls = ["https://github.com/rustsec/advisory-db"]
# ignore = []
git-fetch-with-cli = false # False = use build in git library
yanked = "deny"

[licenses]
version = 2
allow = [
"Apache-2.0", # https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)
"BSD-2-Clause", # https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)
"BSD-3-Clause", # https://tldrlegal.com/license/bsd-3-clause-license-(revised)
"CC0-1.0", # https://creativecommons.org/publicdomain/zero/1.0/
"ISC", # https://tldrlegal.com/license/-isc-license
"LicenseRef-UFL-1.0", # https://tldrlegal.com/license/ubuntu-font-license,-1.0
"MIT", # https://tldrlegal.com/license/mit-license
"OFL-1.1", # https://spdx.org/licenses/OFL-1.1.html
"Unicode-DFS-2016", # https://spdx.org/licenses/Unicode-DFS-2016.html
"Zlib", # https://tldrlegal.com/license/zlib-libpng-license-(zlib)
"MIT-0",
"0BSD",
]
confidence-threshold = 0.93
# exceptions = []
include-dev = true
unused-allowed-license = "warn"

[bans]
multiple-versions = "deny"
multiple-versions-include-dev = false
wildcards = "deny"
highlight = "all"
workspace-default-features = "allow"
external-default-features = "allow"
# allow = [] # Whitelist if one or more entries
# deny = []
skip = [
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected] ", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
{ crate = "[email protected]", reason = "Old version used by other dependency" },
] # Only for duplicate detection
# skip-tree = []

[sources]
unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = []
required-git-spec = "rev"
# private = []

# [sources.allow-org]
# github = []
# gitlab = []
# bitbucket = []
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"egui",
"getresuid",
"landlock",
"Lockdown",
Expand All @@ -10,4 +11,4 @@
"setresuid",
"unistd"
]
}
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Currently nothing

## [0.2.0] - 2024-04-25

### Added

- egui integration

### Changed

- status now via combined struct

## [0.1.0] - 2024-04-21

### Added
Expand Down
20 changes: 17 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "bevy_mod_lockdown"
description = "bevy_mod_lockdown is a library to reduce the attack surface your application offers."
categories = ["game-development"]
keywords = ["bevy", "gamedev"]
version = "0.1.0"
version = "0.2.0"
license = "MIT OR Apache-2.0"
authors = ["Frederik Terstappen <[email protected]>"]
repository = "https://github.com/FrTerstappen/bevy_mod_lockdown"
Expand All @@ -28,9 +28,11 @@ privilege = [
"nix?/user",
]
system_call = []
egui = ["dep:egui"]

[dependencies]
bevy = { version = "0.13.2", default-features = false }
egui = { version = "0.27.2", default-features = false, optional = true }

[target.'cfg(target_os = "android")'.dependencies]

Expand All @@ -47,8 +49,20 @@ nix = { version = "0.28.0", optional = true }
[target.'cfg(target_family = "wasm")'.dependencies]

[target.'cfg(target_os = "windows")'.dependencies]
# To avoid duplication, limited by usage of sysinfo in bevy
windows = { version = "0.52.0", optional = true }
windows = { version = "0.56.0", optional = true }

[dev-dependencies]
bevy = { version = "0.13.2", default-features = true }
bevy_egui = { version = "0.27.0", default-features = false, features = [
"default_fonts",
"render",
] }

[[example]]
name = "egui"
path = "examples/egui.rs"
required-features = ["egui"]


[lints]
# Rust
Expand Down
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ See this [chapter](#status-resources) for more information.
### Status resources

The features each add a resource `FeatureNameAdjustment` that can be used to check the current status of the adjustment.
These resources are enums with variants describing the current status.
They start with a value of `Unknown`.
The resource `LockdownAdjustments` can be used to check the status of the adjustments.
The features each add a field to the resource that matches the feature name.
These fields are enums with variants describing the current status.

## Features

Expand All @@ -41,7 +41,19 @@ You can see the availability of features and their inclusion in full_speed in th
> [!NOTE]
> By default only the feature `feature_warning` is enabled which logs a warning when no other feature is enabled.
### Platform support
### Platform independent features

The features described here are independent of the used platform.

#### Feature: `egui`

Adds a convenience method to display the `LockdownAdjustments` with egui.
See the `egui` example for usage.

Run the example with `cargo run --example egui --features="egui"`.
Include other features to see something beside the warning.

### Platform dependent features

Feature support on different platform:

Expand All @@ -63,7 +75,7 @@ __Legend:__
[^1]: Beside a log entry in some cases.

### Feature: `filesystem`
#### Feature: `filesystem`

Restricts access to the filesystem, blocking access to all not explicitly allowed paths.

Expand All @@ -78,11 +90,11 @@ This happens in `Startup` which means that full access to the file system is sti
Currently only implemented on linux.
Where it uses landlock and requires a kernel with support for it.

### Feature: `network`
#### Feature: `network`

Not yet implemented for any platform.

### Feature: `privilege`
#### Feature: `privilege`

Reduces the privilege granted to the application.

Expand All @@ -91,7 +103,7 @@ Reduces the privilege granted to the application.

This happens in `PostStartup` which means that elevated privileges are still available in `PreStartup`, `Startup` and partly in `PostStartup`.

### Feature: `system_call`
#### Feature: `system_call`

Not yet implemented for any platform.

Expand Down Expand Up @@ -142,4 +154,4 @@ All code in this repository is dual-licensed under either:

| bevy | bevy_mod_lockdown |
| -----: | ----------------: |
| 0.13.1 | 0.1.0 |
| 0.13.1 | 0.1.0 - 0.2.0 |
61 changes: 0 additions & 61 deletions deny.toml

This file was deleted.

28 changes: 28 additions & 0 deletions examples/egui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use bevy::{
prelude::*,
window::PrimaryWindow,
};
use bevy_egui::{
egui,
EguiContext,
EguiPlugin,
};
use bevy_mod_lockdown::LockdownAdjustments;

fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins);
app.add_plugins(EguiPlugin);
app.add_plugins(bevy_mod_lockdown::LockdownPlugin);
app.add_systems(Update, display_adjustment_status);
app.run();
}

fn display_adjustment_status(
mut egui_ctx: Query<&mut EguiContext, With<PrimaryWindow>>,
lockdown_adjustments: Res<'_, LockdownAdjustments>,
) {
egui::Window::new("Example window").show(egui_ctx.single_mut().get_mut(), |ui| {
bevy_mod_lockdown::egui::ui_for_adjustment(ui, &lockdown_adjustments, true);
});
}
31 changes: 31 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[toolchain]
channel = "nightly"
components = [
"rustc",
"cargo",
"rustfmt",
"rust-std",
"clippy",
"miri",
"rust-src",
]
targets = [
# WASM
"wasm32-unknown-unknown",

# Linux
"x86_64-unknown-linux-gnu",

# Mac
"aarch64-apple-darwin",

# iOS
"aarch64-apple-ios",

# Windows
"x86_64-pc-windows-gnu",

# Android
"aarch64-linux-android",
]
profile = "default"
Loading

0 comments on commit 770e914

Please sign in to comment.