Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Volkor/Ephemeral
1 result
Show changes
Commits on Source (3)
...@@ -51,32 +51,32 @@ test: ...@@ -51,32 +51,32 @@ test:
- cargo test -- --nocapture - cargo test -- --nocapture
# Builds the latest master branch commit. # # Builds the latest master branch commit.
docker-build-master: # docker-build-master:
# Official docker image. # # Official docker image.
image: docker:latest # image: docker:latest
stage: build # stage: build
services: # services:
- docker:dind # - docker:dind
before_script: # before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY # - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: # script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" . # - docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE" # - docker push "$CI_REGISTRY_IMAGE"
only: # only:
- master # - master
# Builds the latest of any (other) branch. # # Builds the latest of any (other) branch.
docker-build: # docker-build:
# Official docker image. # # Official docker image.
image: docker:latest # image: docker:latest
stage: build # stage: build
services: # services:
- docker:dind # - docker:dind
before_script: # before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY # - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: # script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . # - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" # - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except: # except:
- master # - master
File moved
...@@ -71,7 +71,8 @@ impl Default for DatabaseConfig { ...@@ -71,7 +71,8 @@ impl Default for DatabaseConfig {
impl Default for LoggingConfig { impl Default for LoggingConfig {
fn default() -> Self { fn default() -> Self {
LoggingConfig { LoggingConfig {
level: "ephemeral=info,sqlx=error,hyper=error,salvo_extra=error,salvo=error,mio=error".to_string(), level: "ephemeral=info,sqlx=error,hyper=error,salvo_extra=error,salvo=error,mio=error"
.to_string(),
metrics: true, metrics: true,
} }
} }
...@@ -88,8 +89,21 @@ impl Default for OperationsConfig { ...@@ -88,8 +89,21 @@ impl Default for OperationsConfig {
file_expiry_min: 604800, file_expiry_min: 604800,
file_expiry_max: 31536000, file_expiry_max: 31536000,
max_filesize: 1073741824, // 10 MB max_filesize: 1073741824, // 10 MB
banned_mimetype: vec!["application/x-msdownload".to_string(), "application/x-msi".to_string(), "application/x-silverlight".to_string(), "application/x-ms-dos-executable".to_string(), "application/vnd.microsoft.portable-executable".to_string()], banned_mimetype: vec![
unsafe_mimetype: vec!["text/html".to_string(), "text/javascript".to_string(), "application/javascript".to_string(), "text/css".to_string(), "application/x-httpd-php".to_string(), "application/xhtml+xml".to_string()], "application/x-msdownload".to_string(),
"application/x-msi".to_string(),
"application/x-silverlight".to_string(),
"application/x-ms-dos-executable".to_string(),
"application/vnd.microsoft.portable-executable".to_string(),
],
unsafe_mimetype: vec![
"text/html".to_string(),
"text/javascript".to_string(),
"application/javascript".to_string(),
"text/css".to_string(),
"application/x-httpd-php".to_string(),
"application/xhtml+xml".to_string(),
],
} }
} }
} }
...@@ -102,4 +116,4 @@ impl Default for UploadConfig { ...@@ -102,4 +116,4 @@ impl Default for UploadConfig {
fallback_key: "set-me".to_string(), fallback_key: "set-me".to_string(),
} }
} }
} }
\ No newline at end of file
...@@ -174,7 +174,8 @@ fn generate_html_tree(tree: &[TreeNode]) -> String { ...@@ -174,7 +174,8 @@ fn generate_html_tree(tree: &[TreeNode]) -> String {
fn generate_html(node: &TreeNode) -> String { fn generate_html(node: &TreeNode) -> String {
// Humanize the time. // Humanize the time.
let key_creation = { let key_creation = {
let datetime: DateTime<Utc> = DateTime::from_timestamp(node.key.creation_time.into(), 0).unwrap(); let datetime: DateTime<Utc> =
DateTime::from_timestamp(node.key.creation_time.into(), 0).unwrap();
let human_time = HumanTime::from(datetime); let human_time = HumanTime::from(datetime);
human_time.to_text_en(Accuracy::Rough, Tense::Past) human_time.to_text_en(Accuracy::Rough, Tense::Past)
}; };
......
...@@ -33,12 +33,13 @@ pub async fn delete_file(req: &mut Request, res: &mut Response, depot: &mut Depo ...@@ -33,12 +33,13 @@ pub async fn delete_file(req: &mut Request, res: &mut Response, depot: &mut Depo
// Grab the file's owner key from the db. // Grab the file's owner key from the db.
let owner = db::check_owner(sqlconn, filename).await; let owner = db::check_owner(sqlconn, filename).await;
debug!("Deletion attempt: user: {} file owner: {:?}", client_key.uuid, owner); debug!(
"Deletion attempt: user: {} file owner: {:?}",
client_key.uuid, owner
);
// Compare the client_key and owner. // Compare the client_key and owner.
let authorized = match owner { let authorized = match owner {
Ok(owner_key) => { Ok(owner_key) => client_key.uuid == owner_key,
client_key.uuid == owner_key
}
Err(_) => false, Err(_) => false,
}; };
debug!("authorized: {}", authorized); debug!("authorized: {}", authorized);
......
...@@ -42,7 +42,8 @@ pub async fn user_profile(req: &mut Request, res: &mut Response, depot: &mut Dep ...@@ -42,7 +42,8 @@ pub async fn user_profile(req: &mut Request, res: &mut Response, depot: &mut Dep
// Humanise the creation date of the API Key. // Humanise the creation date of the API Key.
let key_creation = { let key_creation = {
let datetime: DateTime<Utc> = DateTime::from_timestamp(client_key.creation_time.into(), 0).unwrap(); let datetime: DateTime<Utc> =
DateTime::from_timestamp(client_key.creation_time.into(), 0).unwrap();
let human_time = HumanTime::from(datetime); let human_time = HumanTime::from(datetime);
human_time.to_text_en(Accuracy::Rough, Tense::Present) human_time.to_text_en(Accuracy::Rough, Tense::Present)
}; };
...@@ -158,7 +159,8 @@ pub async fn user_profile(req: &mut Request, res: &mut Response, depot: &mut Dep ...@@ -158,7 +159,8 @@ pub async fn user_profile(req: &mut Request, res: &mut Response, depot: &mut Dep
Ok(key) => { Ok(key) => {
// Humanise the creation_time // Humanise the creation_time
let human_creation_time = { let human_creation_time = {
let datetime: DateTime<Utc> = DateTime::from_timestamp(key.creation_time.into(), 0).unwrap(); let datetime: DateTime<Utc> =
DateTime::from_timestamp(key.creation_time.into(), 0).unwrap();
let human_time = HumanTime::from(datetime); let human_time = HumanTime::from(datetime);
human_time.to_text_en(Accuracy::Rough, Tense::Past) human_time.to_text_en(Accuracy::Rough, Tense::Past)
}; };
......
use figment::{Figment, providers::{Format, Toml, Env}}; use figment::{
providers::{Env, Format, Toml},
Figment,
};
use magic::Cookie; use magic::Cookie;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use salvo::prelude::*; use salvo::prelude::*;
...@@ -74,7 +77,7 @@ async fn main() { ...@@ -74,7 +77,7 @@ async fn main() {
Some(DatabaseType::Sqlite) => { Some(DatabaseType::Sqlite) => {
info!("DB: Using SQLite backend `{}`", &db_url); info!("DB: Using SQLite backend `{}`", &db_url);
// TODO: Check if DB Exists, if not, create. // TODO: Check if DB Exists, if not, create.
let pool = SqlitePool::connect(db_url).await.unwrap(); let pool = SqlitePool::connect(db_url).await.unwrap();
SQLITE.set(pool).unwrap(); SQLITE.set(pool).unwrap();
} }
......