Skip to content

Commit

Permalink
feat(settings): add raw clamd.conf file editor (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele authored Nov 21, 2023
1 parent 04e8fa7 commit 32c72f5
Show file tree
Hide file tree
Showing 52 changed files with 1,712 additions and 365 deletions.
Empty file added .debug/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"rules": {
"@typescript-eslint/no-use-before-define": "off",

"no-null/no-null": "off",

"react/jsx-props-no-spreading": "off",
"react/react-in-jsx-scope": "off"
},
Expand Down
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [ivangabriele]
5 changes: 3 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Create fake /dist directory
run: mkdir ./dist
- name: Run unit tests (with coverage)
run: cargo tarpaulin --exclude glob --frozen --no-fail-fast --out Xml --workspace -- --nocapture
run: cargo tarpaulin --frozen --no-fail-fast --out Xml --workspace -- --nocapture
working-directory: ./src-tauri
- name: Upload tests coverage
uses: codecov/codecov-action@v3
Expand All @@ -112,6 +112,7 @@ jobs:
PROJECT_ROOT_PATH:
${{ matrix.os == 'macos-latest' && '/Users/runner/work/clamav-desktop/clamav-desktop' ||
'D:\a\clamav-desktop\clamav-desktop' }}
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -140,7 +141,7 @@ jobs:
run: cargo build
working-directory: ./src-tauri
- name: Run tests
run: cargo test --exclude glob --no-fail-fast --workspace -- --nocapture
run: cargo test --no-fail-fast --workspace -- --nocapture
working-directory: ./src-tauri

# webview_build:
Expand Down
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ dist
.svelte-kit

########################################
# Custom

# /clamav/build

# Yarn without Zero-Installs
# https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored
.pnp.*
Expand All @@ -154,3 +150,11 @@ dist
!.yarn/releases
!.yarn/sdks
!.yarn/versions

########################################
# Custom

/.debug/*
!/.debug/.gitkeep

# /clamav/build
35 changes: 18 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- [3. Webview with Yarn v3](#3-webview-with-yarn-v3)
- [4. Final Check](#4-final-check)
- [5. Optional requirements](#5-optional-requirements)
- [Local run \& development](#local-run--development)
- [Local development](#local-development)
- [Build a release](#build-a-release)
- [Binary (standalone)](#binary-standalone)
- [Debian-based OS (deb)](#debian-based-os-deb)
Expand Down Expand Up @@ -113,7 +113,7 @@ You should now be able to run `yarn dev` which will launch the application
- [ggshield](https://github.com/GitGuardian/ggshield#installation)
for `yarn test:sec` command.

### Local run & development
### Local development

This will watch for file changes and automatically re-hydrate the webapp on the go:

Expand All @@ -123,8 +123,9 @@ yarn dev

## Build a release

Keep in mind that building a release on your OS generally restrict the release generation to your OS (you can't natively
release a macOS `.dmg` under Ubuntu for example) but you can circumvent that by using VirtualBox (Docker is a hassle to embed macOS & Windows environments).
Keep in mind that building a release on your OS generally restrict the release generation to your OS
(you can't natively release a macOS `.dmg` under Ubuntu for example)
but you can circumvent that by using VirtualBox (Docker is a hassle to embed macOS & Windows environments).

### Binary (standalone)

Expand Down Expand Up @@ -186,15 +187,15 @@ The idea comes from this [Karol Kuczmarski's blog post](http://xion.io/post/code

Commit messages must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) with this types:

- `build`: Anything related to application run or build (build configs, dev configs, scripts, dependencies, etc)
- `ci`: Anything related to continuous integration, including locally (Github Actions, husky, Git, etc)
- `docs`: Anything related to documentation (readme, contributing, website)
- `feat`: Any feature addition, edition or removal
- `fix`: Anything related to documentation (readme, contributing, website)
- `perf`: Any application performance-related change
- `refactor`: Any change in the structure/codebase that doesn't add or change a feature
- `style` Any application UI-releated change (components, styles, assets, etc)
- `test`: Any unit or integration tests change
- `build`: Anything related to application run or build (build configs, dev configs, scripts, dependencies, etc).
- `ci`: Anything related to continuous integration, including locally (Github Actions, husky, Git, etc).
- `docs`: Anything related to documentation (readme, contributing, website).
- `feat`: Any feature addition, edition or removal.
- `fix`: Anything related to documentation (readme, contributing, website).
- `perf`: Any application performance-related change.
- `refactor`: Any change in the structure/codebase that doesn't add or change a feature.
- `style` Any application UI-releated change (components, styles, assets, etc).
- `test`: Any unit or integration tests change.

`feat`, `fix`, `perf`, `refactor`, `style` & `test` types only concerns fixes related to the application istself,
as defined by the scopes below.
Expand All @@ -210,7 +211,7 @@ It's there to help them understand what changed since the last version when a ne

Our official `feat`, `fix`, `perf`, `refactor`, `style` & `test` scopes are:

- `cloud`: Any change impacting the Cloud screen
- `config`: Any change impacting the Config screen
- `dashboard`: Any change impacting the Dashboard screen
- `scanner`: Any change impacting the Scanner screen
- `cloud`: Any change impacting the Cloud screen.
- `dashboard`: Any change impacting the Dashboard screen.
- `scanner`: Any change impacting the Scanner screen.
- `settings`: Any change impacting the Settings screen.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test:
cd ./src-tauri && cargo test --exclude glob --no-fail-fast --workspace -- --nocapture
cd ./src-tauri && cargo test --no-fail-fast --workspace -- --nocapture
test-cover:
cd ./src-tauri && cargo tarpaulin --exclude glob --frozen --no-fail-fast --out Xml --workspace -- --nocapture
cd ./src-tauri && cargo tarpaulin --frozen --no-fail-fast --out Xml --workspace -- --nocapture
test-trace:
export RUST_BACKTRACE=1 && cd ./src-tauri && cargo test --no-fail-fast --workspace -- --nocapture
test-quiet:
Expand Down Expand Up @@ -30,4 +30,4 @@ test-jest-watch:
cd ./src-tauri/jest && cargo watch -x "test -- --nocapture"

upgrade:
cd ./src-tauri && cargo upgrade --exclude glob
cd ./src-tauri && cargo upgrade
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ This roadmap is not set in stone and is prone to change unexpectedly while we're
#### v.0.4.0

- [x] Cloud: Definitions update
- [ ] Config: Raw clamd.conf editor
- [x] Dashboard: Daemon control & status
- [x] Global: Tray icon
- [x] Scanner: Drives selection
- [x] Scanner: Folders selection
- [x] Scanner: Scan interruption
- [x] Settings: Raw clamd.conf editor
- [ ] Technical: Releases in `.x64.deb`, `.x64.dmg`, and `.x64.msi` formats

#### v.0.5.0
Expand All @@ -79,10 +79,10 @@ This roadmap is not set in stone and is prone to change unexpectedly while we're

#### v.0.?.0

- [ ] Config: Form-like `clamd.conf` editor
- [ ] Global: Automated updates (if/where possible)
- [ ] Publication: OpenSuse Build availibility (to challenge)
- [ ] Publication: PPA availibility
- [ ] Settings: Form-like `clamd.conf` editor
- [ ] Technical: macOS & Windows Code signing
- [ ] Technical: Binaries embedding (check with official ClamAV team)
- [ ] Technical: Releases `.x64.rpm` and `.arm64.rpm` formats
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
"postversion": "git push origin HEAD --tags"
},
"dependencies": {
"@lezer/highlight": "1.2.0",
"@tauri-apps/api": "1.5.1",
"@uiw/codemirror-extensions-langs": "4.21.20",
"@uiw/codemirror-themes": "4.21.20",
"@uiw/react-codemirror": "4.21.20",
"ky-universal": "0.12.0",
"lodash.debounce": "4.0.8",
"lodash.throttle": "4.1.1",
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ tauri-build = { version = "1.5.0", features = [] }
[dependencies]
chrono = "0.4.31"
cli = { path = "./cli" }
dev = { path = "./dev" }
filer = { path = "./filer" }
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.5.2", features = ["api-all", "icon-png", "system-tray"] }
lazy_static = "1.4.0"
regex = "1.10.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.108"
tauri = { version = "1.5.2", features = ["api-all", "icon-png", "system-tray"] }
tokio = { version = "1.34.0", features = ["full"] }
tokio-util = "0.7.10"
lazy_static = "1.4.0"
walkdir = "2.4.0"

[dev-dependencies]
jrest = "0.2.3"
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
colored = "2.0.0"
common = { path = "../common" }
Expand Down
8 changes: 2 additions & 6 deletions src-tauri/cli/tests/test_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ use jrest::expect;
#[test]
fn runs_returns_the_expected_output() {
// TODO Add Windows test.
// TODO Add macOS test.
if cfg!(linux) {
if cfg!(unix) {
let command = "ls".to_string();
let args = vec![
"-al".to_string(),
dev::get_sample_directory_absolute_path_option().unwrap(),
];
let args = vec!["-al".to_string(), dev::get_sample_directory_path()];

let stdout_callback = |index: usize, line: String| match index {
0 => {
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "common"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dev-dependencies]
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "dev"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dev-dependencies]
Expand Down
33 changes: 23 additions & 10 deletions src-tauri/dev/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
use std::{env, path::Path};

#[cfg(not(tarpaulin_include))]
pub fn get_sample_directory_absolute_path_option() -> Option<String> {
let project_root_path_as_string = env::var("PROJECT_ROOT_PATH").unwrap();
let project_root_path_as_str = &*project_root_path_as_string;
fn construct_path_from_root(root_path: &str, relative_path: &[&str]) -> String {
let mut path_as_path_buf: std::path::PathBuf = Path::new(&root_path).to_path_buf();

Some(
Path::new(project_root_path_as_str)
.join("e2e/samples/directory")
.as_os_str()
.to_str()
.unwrap()
.to_string(),
for component in relative_path {
path_as_path_buf = path_as_path_buf.join(component);
}

path_as_path_buf
.to_str()
.expect("Failed to convert `Path` to `&str`.")
.to_string()
}

#[cfg(not(tarpaulin_include))]
pub fn get_debug_clamd_conf_file_path() -> String {
construct_path_from_root("", &["..", ".debug", "clamd.conf"])
}
#[cfg(not(tarpaulin_include))]
pub fn get_sample_directory_path() -> String {
construct_path_from_root(
env::var("PROJECT_ROOT_PATH")
.expect("Failed to get `PROJECT_ROOT_PATH` environment variable.")
.as_str(),
&["e2e", "samples", "directory"],
)
}
2 changes: 0 additions & 2 deletions src-tauri/fast-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ name = "fast-cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.34.0", features = ["full"] }
2 changes: 0 additions & 2 deletions src-tauri/filer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name = "filer"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cli = { path = "../cli" }
common = { path = "../common" }
Expand Down
4 changes: 0 additions & 4 deletions src-tauri/filer/src/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ use common;
const EMPTY_STRING_VECTOR: Vec<String> = Vec::new();

pub fn list() -> Vec<String> {
if cfg!(macos) {
return vec!["/".to_string()];
}

if cfg!(unix) {
return vec!["/".to_string()];
}
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/filer/tests/file_explorer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use filer;
#[test]
fn file_explorer_toggle_is_checked_into_tree_returns_the_expected_file_paths_tree() {
let is_recursive = false;
let directory_absolute_path_option = dev::get_sample_directory_absolute_path_option();
let directory_absolute_path_option = dev::get_sample_directory_path();
let file_kind_option = Some(filer::types::FileKind::Directory);

let mut file_explorer = filer::file_list::list(
is_recursive,
directory_absolute_path_option,
Some(directory_absolute_path_option),
file_kind_option,
)
.into_file_explorer();
Expand Down Expand Up @@ -152,12 +152,12 @@ fn file_explorer_toggle_is_checked_into_tree_returns_the_expected_file_paths_tre
#[test]
fn file_explorer_toggle_is_expanded_into_tree_returns_the_expected_file_paths_tree() {
let is_recursive = false;
let directory_absolute_path_option = dev::get_sample_directory_absolute_path_option();
let directory_absolute_path_option = dev::get_sample_directory_path();
let file_kind_option = Some(filer::types::FileKind::Directory);

let mut file_explorer = filer::file_list::list(
is_recursive,
directory_absolute_path_option,
Some(directory_absolute_path_option),
file_kind_option,
)
.into_file_explorer();
Expand Down
Loading

0 comments on commit 32c72f5

Please sign in to comment.