Skip to content

Commit a0e779f

Browse files
committed
wip: continue db refactor
1 parent 074fffe commit a0e779f

File tree

34 files changed

+274
-113
lines changed

34 files changed

+274
-113
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ virtual and controlled by a corporation, like accounts on _github.com_. Others
2323
have a physical component as well, like a server in your closet, Raspberry Pi,
2424
or laptop.
2525

26-
All of these entities are part of your _virtual estate_ and are often
27-
intricately connected in various ways. As an example, you might have an SSH key
28-
or API token on your machine that grants access to repositories (a kind of
29-
digital asset) on Github. And suppose your machine also has an authorized key
30-
installed that allows access from another machine:
26+
All of these entities are part of your _virtual estate_ and are intricately
27+
connected in various ways. As an example, you might have an SSH key or API token
28+
on your machine that grants access to repositories (a kind of digital asset) on
29+
Github. And suppose your machine also has an authorized key installed that
30+
allows access from another machine:
3131

3232
```
3333
┌──────────┐ SSH Key ┌──────────┐ API Token ┌───────────────────┐
@@ -37,18 +37,18 @@ installed that allows access from another machine:
3737
└───────────────────┘
3838
```
3939

40-
If you care about those repos, then Sandpolis can map out an attack surface that
41-
includes both `Machine A` and `Machine B`. If `Machine A` happens to have a weak
42-
password or one that's shared with another website, then the attack surface is
43-
consequently expanded with appropriate probabilities.
40+
If those private repos are worth protecting, then Sandpolis can map out an
41+
attack surface that includes both `Machine A` and `Machine B`. If `Machine A`
42+
happens to have a weak password or one that's shared with another website, then
43+
the attack surface is consequently expanded with appropriate probabilities.
4444

4545
Mapping these relationships automatically is possible because Sandpolis runs an
46-
agent on `Machine A` and `Machine B` (and has API access to Github).
46+
agent on `Machine A` and `Machine B`.
4747

4848
## Security Warning
4949

5050
Sandpolis is an extremely high-value attack target as it provides management
51-
access to your virtual estate. To compensate, strong security measures are
51+
capabilities on your virtual estate. To compensate, strong security measures are
5252
available:
5353

5454
- All connections to a server use mTLS and require a valid client certificate.
@@ -87,7 +87,7 @@ Models online/offline accounts and their relationships to agent instances.
8787
Enables higher-order analysis of virtual estate like attack surface mapping and
8888
compromise tracing.
8989

90-
### Alert
90+
### Audit
9191

9292
Triggers user notifications when certain events are detected in the Sandpolis
9393
network. For example, if a user's status is currently _AWAY_, an unexpected SSH
@@ -100,13 +100,11 @@ Provides access to remote desktop capabilities.
100100
### Filesystem
101101

102102
Provides read/write access to agent filesystems. The Sandpolis client can also
103-
mount an agent's filesystem.
104-
105-
### Logging
103+
mount an agent's filesystem with FUSE.
106104

107105
### Package
108106

109-
Integrates with package managers to monitor package versions.
107+
Integrates with package managers to monitor software versions.
110108

111109
### Probe
112110

@@ -119,11 +117,16 @@ the gateway instance remains online).
119117

120118
### Shell
121119

122-
Provides an interactive remote shell.
120+
Provides an interactive remote shell. Also stores customizable shell "snippets"
121+
that can be executed on a schedule.
123122

124123
### Tunnel
125124

126-
### User
125+
Establishes a permanent or ephemeral TCP tunnel between arbitrary instances.
126+
127+
### Snapshot
128+
129+
Create and apply _cold snapshots_ via a boot agent.
127130

128131
## Installation
129132

@@ -163,9 +166,9 @@ perform any excluded functionality.
163166
```yml
164167
# Docker compose
165168
services:
166-
sandpolis-server:
167-
image: sandpolis/server
168-
restart: unless-stopped
169+
sandpolis-server:
170+
image: sandpolis/server
171+
restart: unless-stopped
169172
```
170173
171174
#### Install client from DockerHub

sandpolis-account/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ built = { version = "0.8", features = ["git2", "chrono", "semver"] }
1111
[dependencies]
1212
anyhow = { workspace = true }
1313
validator = { workspace = true }
14+
native_db = { workspace = true }
15+
native_model = { workspace = true }
1416
serde = { workspace = true }
1517
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
1618
sandpolis-instance = { path = "../sandpolis-instance", version = "0.0.1" }
1719
sandpolis-database = { path = "../sandpolis-database", version = "0.0.1" }
20+
sandpolis-macros = { path = "../sandpolis-macros", version = "0.0.1" }
1821

1922
[features]
2023
client = []

sandpolis-account/src/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
//! This layer enables account-level management.
22
3+
use anyhow::Result;
4+
use native_db::*;
5+
use native_model::{Model, native_model};
36
use sandpolis_core::InstanceId;
4-
use sandpolis_database::DatabaseLayer;
7+
use sandpolis_database::{Data, DataIdentifier, DatabaseLayer, Watch};
8+
use sandpolis_macros::Data;
59
use serde::{Deserialize, Serialize};
610
use validator::Validate;
711

12+
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Debug, Data)]
13+
#[native_model(id = 27, version = 1)]
14+
#[native_db]
15+
pub struct AccountLayerData {
16+
#[primary_key]
17+
pub _id: DataIdentifier,
18+
}
19+
20+
#[derive(Clone)]
821
pub struct AccountLayer {
922
database: DatabaseLayer,
1023
}
1124

25+
impl AccountLayer {
26+
pub async fn new() -> Result<Self> {
27+
Ok(Self { database: todo!() })
28+
}
29+
}
30+
1231
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1332
pub struct AccountId(u128);
1433

sandpolis-agent/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ tokio-cron-scheduler = { version = "0.14.0", optional = true }
1515
sandpolis-network = { path = "../sandpolis-network", version = "0.0.1" }
1616
sandpolis-database = { path = "../sandpolis-database", version = "0.0.1" }
1717
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
18+
sandpolis-macros = { path = "../sandpolis-macros", version = "0.0.1" }
1819

1920
[features]
2021
agent = ["dep:tokio-cron-scheduler"]

sandpolis-audit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ native_model = { workspace = true }
1414
sandpolis-instance = { path = "../sandpolis-instance", version = "0.0.1" }
1515
sandpolis-database = { path = "../sandpolis-database", version = "0.0.1" }
1616
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
17+
sandpolis-macros = { path = "../sandpolis-macros", version = "0.0.1" }
1718

1819
[features]
1920
server = []

sandpolis-database/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl DatabaseLayer {
8686
/// `Data` is what's stored in a database!
8787
pub trait Data
8888
where
89-
Self: ToInput + Default + Clone + PartialEq + Send + Sync,
89+
Self: ToInput + Clone + PartialEq + Send + Sync,
9090
{
9191
fn id(&self) -> DataIdentifier;
9292
fn set_id(&mut self, id: DataIdentifier);
@@ -191,7 +191,7 @@ impl<T: Data> Drop for Watch<T> {
191191
}
192192
}
193193

194-
impl<T: Data + 'static> Watch<T> {
194+
impl<T: Data + Default + 'static> Watch<T> {
195195
/// Create a new `Watch` when there's only one row in the database.
196196
pub fn singleton(db: Arc<native_db::Database<'static>>) -> Result<Self> {
197197
let r = db.r_transaction()?;

sandpolis-deploy/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ os_info = { workspace = true }
1212
russh = { workspace = true, optional = true }
1313
sandpolis-core = { path = "../sandpolis-core", version = "0.0.1" }
1414
sandpolis-group = { path = "../sandpolis-group", version = "0.0.1" }
15+
sandpolis-macros = { path = "../sandpolis-macros", version = "0.0.1" }
1516

1617
[features]
1718
agent = ["dep:russh"]

sandpolis-desktop/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::Result;
12
use axum::Router;
23

34
pub(crate) mod messages;
@@ -11,4 +12,10 @@ pub mod client;
1112
#[derive(Clone)]
1213
pub struct DesktopLayer {}
1314

15+
impl DesktopLayer {
16+
pub async fn new() -> Result<Self> {
17+
Ok(Self {})
18+
}
19+
}
20+
1421
// TODO agent lists available desktops for db

sandpolis-filesystem/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod messages;
1010
pub struct FilesystemLayer {}
1111

1212
impl FilesystemLayer {
13-
pub fn new() -> Result<Self> {
13+
pub async fn new() -> Result<Self> {
1414
Ok(Self {})
1515
}
1616
}

0 commit comments

Comments
 (0)