From ea2acc0fde3586d37d0365afddffcb1f8fbf80fa Mon Sep 17 00:00:00 2001 From: Yves Zoundi Date: Fri, 8 Jul 2022 19:02:22 -0400 Subject: [PATCH] Preparing 0.2.1 release - Update documentation - Update translations - Minor optimizations - Speed up CI/CD local builds --- README.org | 16 +++++----- RELEASING.org | 9 +++--- TODO.org | 10 +++---- ci_cd/linux/build.sh | 24 +++------------ ci_cd/macos/build.sh | 29 ++----------------- ci_cd/windows/build.sh | 22 ++------------ entrusted_client/src/common.rs | 10 ++++--- entrusted_client/src/container.rs | 10 +++---- entrusted_client/src/main_cli.rs | 27 ++++++++--------- entrusted_client/src/main_gui.rs | 11 +++---- .../translations/en/LC_MESSAGES/messages.po | 2 +- .../translations/fr/LC_MESSAGES/messages.po | 4 +-- entrusted_client/translations/messages.pot | 2 +- entrusted_container/README.org | 6 ++-- entrusted_container/src/main.rs | 2 +- entrusted_webserver/src/server.rs | 7 ++--- entrusted_webserver/web-assets/index.html | 6 ++-- 17 files changed, 73 insertions(+), 124 deletions(-) diff --git a/README.org b/README.org index 34136be..7841ad3 100644 --- a/README.org +++ b/README.org @@ -7,6 +7,7 @@ =Entrusted= is a document sanitizer tool that converts "/potentially suspicious files/" into /safe PDFs/: - This is achieved by transforming documents inside a "lightweight sandbox" ([[https://www.ibm.com/cloud/learn/containerization][containerization]]): =containerization= itself does not provide absolute security guarantees... - Supported file formats include PDF, common image formats, Office documents ([[https://www.office.com/][Microsoft Office]] or [[https://www.libreoffice.org/discover/what-is-opendocument/][OpenDocument]]). For Office documents, supported is limited to text documents, spreadsheets and presentations. +- The progam was originally a [[https://www.rust-lang.org/][Rust]] port of [[https://dangerzone.rocks/][Dangerzone]], for experimentation purposes *NOTE*: Unless you use the live CD, you MUST install either [[https://www.docker.com/products/docker-desktop/][Docker]] or [[https://podman.io/getting-started/][Podman]] prior running the program. @@ -18,8 +19,7 @@ Below are some screenshots of the graphical Desktop client running on Mac OS. ** Features -This application is a [[https://www.rust-lang.org/][Rust]] port of [[https://dangerzone.rocks/][Dangerzone]], originally for experimentation purposes (/not an exact port/). -- Similarly to the original /Dangerzone/ tool, documents or images are converted inside a "sandbox" +- Documents or images are converted inside a "sandbox" - Documents can be converted in batch (sequential conversions for now) - There is support for password-protected documents (known Office document formats and PDF files) - An optional Web interface is available and can act as an "online service" (towards multi-tenancy) @@ -28,7 +28,7 @@ This application is a [[https://www.rust-lang.org/][Rust]] port of [[https://dan - Pre-installed [[https://xebia.com/blog/podman-the-free-container-engine-alternative-to-docker/][container solution]], with no required user configuration ([[./entrusted_webserver][entrusted_webserver]]) - Extra isolation layer with a virtual machine - The application supports multiple languages (English and French for now) -- On Mac OS, [[https://github.com/lima-vm/lima][Lima]] is supported as an alternative to [[https://www.docker.com/products/docker-desktop/][Docker]] +- On Mac OS, [[https://github.com/lima-vm/lima][Lima]] is supported as an alternative to [[https://www.docker.com/products/docker-desktop/][Docker]] (default /Lima/ instance) * What is available? @@ -36,7 +36,7 @@ This application is a [[https://www.rust-lang.org/][Rust]] port of [[https://dan There are 3 user interfaces ([[./entrusted_client][Desktop and CLI]], [[./entrusted_webserver][Web]]) - Most users will likely want the Desktop version -- If you prefer the Web interface, please download the live CD ISO for an "out of the box non-involved user experience" (/unless you'd rather setup the Web server yourself/): +- If you prefer the Web interface, please download the live CD for an out-of-the-box user experience: - You can run the live CD with tools such as [[https://www.qemu.org/][QEMU]], [[https://www.virtualbox.org/wiki/Downloads][VirtualBox]], [[https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v][Hyper-V]], [[https://www.vmware.com/nl/products/workstation-player.html][VmWare]], [[https://www.parallels.com/][Parallels]], etc. - The Web UI is available at =http://localhost:13000= - Replace =localhost= by the IP address of your virtual machine in the above-mentioned link @@ -56,7 +56,7 @@ For downloads, please visit the [[https://github.com/rimerosolutions/entrusted/r | =MS Windows= | =entrusted-windows-amd64-.exe= | Installer with the Desktop and CLI clients | | | =entrusted-windows-amd64-.zip= | Archive with all the programs | |------------------+-----------------------------------------+--------------------------------------------| -| =Live CD= | =entrusted-livecd-amd64-.iso= | Web interface deployed in VM | +| =Live CD= | =entrusted-livecd-amd64-.iso= | Web interface Live CD | |------------------+-----------------------------------------+--------------------------------------------| ** Key software components @@ -71,7 +71,7 @@ Most users will interact with the =entrusted_client=, via its Desktop user inter | [[./entrusted_container][entrusted_container]] | Document processing "sandbox" | | [[./entrusted_client][entrusted_client]] | Command-line and graphical user interfaces | | [[./entrusted_webserver][entrusted_webserver]] | Online service feature with a Web interface | -| [[./entrusted_webclient][entrusted_webclient]] | Command-line client for the =webserver= | +| [[./entrusted_webclient][entrusted_webclient]] | Command-line client for the =web server= | | [[./entrusted_l10n][entrusted_l10n]] | Shared library for translation features | |---------------------+---------------------------------------------| @@ -88,9 +88,9 @@ Below is a high-level architecture overview, the solution relies on a container - Mostly Linux has been tested - BSD users can probably use the "Online service" from the Live CD ISO (via VirtualBox, etc.) - *Container Runtime*: [[https://podman.io/][Podman]], [[https://www.docker.com/][Docker]] or [[https://github.com/lima-vm/lima][Lima]] - - On Linux, please install Podman - - On Windows, Docker is recommended + - On Linux, please install Podman or Docker - On Mac OS, please use either Docker or Lima + - On Windows, Docker is recommended Conversions will fail if the container solution is not running or available in your [[https://www.java.com/en/download/help/path.html]["PATH settings"]]: - The tool doesn't attempt to modify software on your machine (install or change other programs) diff --git a/RELEASING.org b/RELEASING.org index 82ab0ea..d09c69e 100644 --- a/RELEASING.org +++ b/RELEASING.org @@ -2,20 +2,21 @@ General steps: -- Review and update the README page for impacted components as needed -- Bump the version of the application +- Review and update the README page for impacted components (/if needed/) +- Bump the version of the application at several places for now... - Bump the =version= field in all the projects (=Cargo.toml= files) - The container image tag is inferred from the release version to standardize as much as possible - Please try to follow closely [[https://semver.org/][semantic versioning]] - Bump the =version= field in the /Dockerfile/ for the label =org.opencontainers.image.version= + - Bump the version in the HTML title for =entrusted_webserver/web-assets/index.html= - On a recent Ubuntu Linux installation, build all the release artifacts =ci_cd/build_all.sh= - - This generates all the release artifacts under a new folder called =packages= + - This generates release artifacts under a new folder called =packages= - You can then test the resulting archives and executables under Linux, Mac OS and Windows - You can test the live CD ISO image with a tool such as [[https://www.qemu.org/][QEMU]] or the software of your choice - Merge the current branch into the =main= branch, and push the changes - Tag the main branch with the new =release version= (i.e. =1.1.1=) and push the changes - Push the container image to [[https://hub.docker.com/r/uycyjnzgntrn/entrusted_container][Docker Hub]] per [[./entrusted_container/README.org][publishing instructions]] -- Create a new release from the GitHub Web interface: +- Create a new GitHub release from its Web interface: - Add the release notes - Upload all release artifacts (=exe=, =dmg=, =zip=, =tar= and =iso= files) - Publish the release diff --git a/TODO.org b/TODO.org index 8cda3e7..ce435c7 100644 --- a/TODO.org +++ b/TODO.org @@ -3,30 +3,30 @@ * Next steps - [-] Code maintenance + - [X] Eliminate shell commands inside the container image - [ ] Add automated tests (unit & integration) - [ ] Code cleanup and refactoring - [ ] More idiomatic Rust code - [ ] Simplify and clarify the code - - [X] Eliminate shell commands inside the container image - [ ] Online Web Service - [ ] Serve Web UI translations at once, instead of a second request on page load - [ ] Use the =Content-Language= header in response (translations) - [ ] Revisit notifications SSE + HTTP2, for the "Online Service" - [ ] Investigate if specific support is required for Tails Linux - [-] CI/CD - - [ ] Transition CI/CD scripts to Github actions or TravisCI or something else? - [X] Adopt Git flow and delete all the previous spiral branches + - [ ] Transition CI/CD scripts to Github actions or TravisCI or something else? - [ ] Create few specific packages (DEB, RPM) - [ ] Hardening - [ ] Review container execution options (podman v.s podman-remote, security options, etc.) - [ ] Revisit Flatpak support requirements and =flatpak-spawn= - [ ] Review some of the code and read few security-related articles - [-] Improved conversions - - [ ] Parallel conversions - - [ ] Minimal resources management to avoid exhausting computer CPU and memory - - [ ] Cancellable conversions for those that haven't started yet - [X] Custom output location for individual documents in the conversion queue - [X] Support for password-protected documents + - [ ] Cancellable conversions for those that haven't started yet + - [ ] Parallel conversions + - [ ] Minimal resources management to avoid exhausting computer CPU and memory - [ ] Performance - [ ] Mime-type detection - [ ] Avoid reading entire files for mime type detection, just what is required... diff --git a/ci_cd/linux/build.sh b/ci_cd/linux/build.sh index a533866..35a89e2 100755 --- a/ci_cd/linux/build.sh +++ b/ci_cd/linux/build.sh @@ -29,34 +29,18 @@ if [ $retVal -ne 0 ]; then exit 1 fi -echo "Building entrusted_client (entrusted-cli)" +echo "Building other Linux binaries" cd ${PROJECTDIR} -podman run --rm --volume "${PWD}":/root/src --workdir /root/src docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 sh -c "RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_client/Cargo.toml --bin entrusted-cli" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi -cp ${PROJECTDIR}/entrusted_client/target/x86_64-unknown-linux-musl/release/entrusted-cli ${ARTIFACTSDIR} +podman run --rm --volume "${PWD}":/root/src --workdir /root/src docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 sh -c "RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_client/Cargo.toml --bin entrusted-cli && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_webserver/Cargo.toml && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_webclient/Cargo.toml" -echo "Building entrusted_webserver" -cd ${PROJECTDIR} -podman run --rm --volume "${PWD}":/root/src --workdir /root/src docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 sh -c "RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_webserver/Cargo.toml" retVal=$? if [ $retVal -ne 0 ]; then echo "Failure" exit 1 fi -cp ${PROJECTDIR}/entrusted_webserver/target/x86_64-unknown-linux-musl/release/entrusted-webserver ${ARTIFACTSDIR} -echo "Building entrusted_webclient" -cd ${PROJECTDIR} -podman run --rm --volume "${PWD}":/root/src --workdir /root/src docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 sh -c "RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl --manifest-path /root/src/entrusted_webclient/Cargo.toml" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi +cp ${PROJECTDIR}/entrusted_client/target/x86_64-unknown-linux-musl/release/entrusted-cli ${ARTIFACTSDIR} +cp ${PROJECTDIR}/entrusted_webserver/target/x86_64-unknown-linux-musl/release/entrusted-webserver ${ARTIFACTSDIR} cp ${PROJECTDIR}/entrusted_webclient/target/x86_64-unknown-linux-musl/release/entrusted-webclient ${ARTIFACTSDIR} cp ${SCRIPTDIR}/release_README.txt ${ARTIFACTSDIR}/README.txt diff --git a/ci_cd/macos/build.sh b/ci_cd/macos/build.sh index b152cbd..6cf196b 100755 --- a/ci_cd/macos/build.sh +++ b/ci_cd/macos/build.sh @@ -16,44 +16,21 @@ rm -rf ${PROJECTDIR}/entrusted_webserver/target cd ${PROJECTDIR} -echo "Building entrusted_client" +echo "Building all Mac OS binaries" podman run --rm \ --volume "${PROJECTDIR}":/root/src \ --workdir /root/src \ docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 \ - sh -c "export CC=/usr/local/osxcross/target/bin/o64-clang; export CXX=/usr/local/osxcross/target/bin/o64-clang++; cd /root/src/entrusted_client && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin" + sh -c "export CC=/usr/local/osxcross/target/bin/o64-clang; export CXX=/usr/local/osxcross/target/bin/o64-clang++; cd /root/src/entrusted_client && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin; cd /root/src/entrusted_webclient && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin; cd /root/src/entrusted_webserver && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin" retVal=$? if [ $retVal -ne 0 ]; then echo "Failure" exit 1 fi + cp ${PROJECTDIR}/entrusted_client/target/x86_64-apple-darwin/release/entrusted-cli ${ARTIFACTSDIR} cp ${PROJECTDIR}/entrusted_client/target/x86_64-apple-darwin/release/entrusted-gui ${ARTIFACTSDIR} - -echo "Building entrusted_webclient" -podman run --rm \ - --volume "${PROJECTDIR}":/root/src \ - --workdir /root/src \ - docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 \ - sh -c "export CC=/usr/local/osxcross/target/bin/o64-clang; export CXX=/usr/local/osxcross/target/bin/o64-clang++; cd /root/src/entrusted_webclient && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi cp ${PROJECTDIR}/entrusted_webclient/target/x86_64-apple-darwin/release/entrusted-webclient ${ARTIFACTSDIR} - -echo "Building entrusted_webserver" -podman run --rm \ - --volume "${PROJECTDIR}":/root/src \ - --workdir /root/src \ - docker.io/joseluisq/rust-linux-darwin-builder:1.60.0 \ - sh -c "export CC=/usr/local/osxcross/target/bin/o64-clang; export CXX=/usr/local/osxcross/target/bin/o64-clang++; cd /root/src/entrusted_webserver && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi cp ${PROJECTDIR}/entrusted_webserver/target/x86_64-apple-darwin/release/entrusted-webserver ${ARTIFACTSDIR} diff --git a/ci_cd/windows/build.sh b/ci_cd/windows/build.sh index a858268..032742b 100755 --- a/ci_cd/windows/build.sh +++ b/ci_cd/windows/build.sh @@ -18,33 +18,17 @@ rm -rf ${PROJECTDIR}/entrusted_webserver/target cd ${PROJECTDIR} -echo "Building entrusted_client" -podman run --rm --privileged -v "${PROJECTDIR}":/src docker.io/uycyjnzgntrn/rust-windows:1.60.0 sh -c "cd /src/entrusted_client && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu" +echo "Building all Windows binaries" +podman run --rm --privileged -v "${PROJECTDIR}":/src docker.io/uycyjnzgntrn/rust-windows:1.60.0 sh -c "cd /src/entrusted_client && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu && cd /src/entrusted_webserver && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu && cd /src/entrusted_webclient && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu" retVal=$? if [ $retVal -ne 0 ]; then echo "Failure" exit 1 fi + cp ${PROJECTDIR}/entrusted_client/target/x86_64-pc-windows-gnu/release/entrusted-cli.exe ${ARTIFACTSDIR}/ cp ${PROJECTDIR}/entrusted_client/target/x86_64-pc-windows-gnu/release/entrusted-gui.exe ${ARTIFACTSDIR}/ - - -echo "Building entrusted_webserver" -podman run --rm --privileged -v "${PROJECTDIR}":/src docker.io/uycyjnzgntrn/rust-windows:1.60.0 sh -c "cd /src/entrusted_webserver && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi cp ${PROJECTDIR}/entrusted_webserver/target/x86_64-pc-windows-gnu/release/entrusted-webserver.exe ${ARTIFACTSDIR}/ - -echo "Building entrusted_webclient" -podman run --rm --privileged -v "${PROJECTDIR}":/src docker.io/uycyjnzgntrn/rust-windows:1.60.0 sh -c "cd /src/entrusted_webclient && RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-pc-windows-gnu" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failure" - exit 1 -fi cp ${PROJECTDIR}/entrusted_webclient/target/x86_64-pc-windows-gnu/release/entrusted-webclient.exe ${ARTIFACTSDIR}/ echo "Generate windows installer" diff --git a/entrusted_client/src/common.rs b/entrusted_client/src/common.rs index 6a103bd..92b0fb1 100644 --- a/entrusted_client/src/common.rs +++ b/entrusted_client/src/common.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; pub const CONTAINER_IMAGE_EXE: &str = "/usr/local/bin/entrusted-container"; pub const ENV_VAR_ENTRUSTED_DOC_PASSWD: &str = "ENTRUSTED_DOC_PASSWD"; +pub const LOG_FORMAT_JSON: &str = "json"; #[macro_export] macro_rules! incl_gettext_files { @@ -97,9 +98,10 @@ pub fn container_runtime_path<'a>() -> Option> { ContainerProgramStub::Podman(cmd, sub_cmd_args, cmd_args, tmp_dir_opt) | ContainerProgramStub::Lima(cmd, sub_cmd_args, cmd_args, tmp_dir_opt) => { if let Some(path_container_exe) = executable_find(cmd) { - let suggested_tmp_dir = match tmp_dir_opt { - None => None, - Some(tmp_dir) => Some(PathBuf::from(tmp_dir)) + let suggested_tmp_dir = if let Some(tmp_dir) = tmp_dir_opt { + Some(PathBuf::from(tmp_dir)) + } else { + None }; return Some(ContainerProgram::new(path_container_exe, sub_cmd_args.clone(), cmd_args.clone(), suggested_tmp_dir)); } @@ -115,7 +117,7 @@ pub fn default_output_path(input: PathBuf, file_suffix: String) -> Result = if convert_options.log_format == "plain".to_string() { - Box::new(PlainLogPrinter {}) + Box::new(PlainLogPrinter) } else { - Box::new(JsonLogPrinter {}) + Box::new(JsonLogPrinter) }; tx.send(printer.print(1, format!("{} {}.", trans.gettext("Converting"), input_path.display())))?; @@ -305,8 +305,8 @@ pub fn convert(input_path: PathBuf, output_path: PathBuf, convert_options: commo err_msg.push_str(&trans.gettext("Please install Docker.")); } else if cfg!(any(target_os="macos")) { err_msg.push_str(&trans.gettext("Please install Docker or Lima.")); - } else { - err_msg.push_str(&trans.gettext("Please install Podman.")); + } else { // Linux and others + err_msg.push_str(&trans.gettext("Please install Docker or Podman.")); } } diff --git a/entrusted_client/src/main_cli.rs b/entrusted_client/src/main_cli.rs index bc8a567..bc0a10e 100644 --- a/entrusted_client/src/main_cli.rs +++ b/entrusted_client/src/main_cli.rs @@ -16,7 +16,6 @@ mod config; mod container; const LOG_FORMAT_PLAIN: &str = "plain"; -const LOG_FORMAT_JSON: &str = "json"; fn main() -> Result<(), Box> { l10n::load_translations(incl_gettext_files!("en", "fr")); @@ -77,7 +76,7 @@ fn main() -> Result<(), Box> { Arg::with_name("log-format") .long("log-format") .help(&help_log_format) - .possible_values(&[LOG_FORMAT_JSON, LOG_FORMAT_PLAIN]) + .possible_values(&[common::LOG_FORMAT_JSON, LOG_FORMAT_PLAIN]) .default_value(LOG_FORMAT_PLAIN) .required(false) .takes_value(true) @@ -120,7 +119,7 @@ fn main() -> Result<(), Box> { let supported_ocr_languages = l10n::ocr_lang_key_by_name(trans.clone_box()); if supported_ocr_languages.contains_key(proposed_ocr_lang) { - ocr_lang = Some(format!("{}", proposed_ocr_lang)); + ocr_lang = Some(proposed_ocr_lang.to_string()); } else { let mut ocr_lang_err = String::new(); ocr_lang_err.push_str(&trans.gettext_fmt("Unknown language code for the ocr-lang parameter: {0}. Hint: Try 'eng' for English.", vec![proposed_ocr_lang])); @@ -156,7 +155,7 @@ fn main() -> Result<(), Box> { } let container_image_name = match &run_matches.value_of("container-image-name") { - Some(img) => format!("{}", img), + Some(img) => img.to_string(), None => if let Some(container_image_name_saved) = app_config.container_image_name { container_image_name_saved.clone() } else { @@ -165,8 +164,8 @@ fn main() -> Result<(), Box> { }; let log_format = match &run_matches.value_of("log-format") { - Some(fmt) => fmt.to_string(), - None => LOG_FORMAT_PLAIN.to_string() + Some(fmt) => fmt, + None => LOG_FORMAT_PLAIN }; let opt_passwd = if run_matches.is_present("passwd-prompt") { @@ -175,8 +174,9 @@ fn main() -> Result<(), Box> { Some(env_passwd) } else { println!("{}", trans.gettext("Please enter the password for the document")); - if let Ok(password) = rpassword::read_password() { - Some(password) + + if let Ok(passwd) = rpassword::read_password() { + Some(passwd) } else { return Err(trans.gettext("Failed to read password!").into()); } @@ -188,16 +188,17 @@ fn main() -> Result<(), Box> { let (tx, rx) = channel(); let exec_handle = thread::spawn(move || { - let convert_options = common::ConvertOptions::new(container_image_name, String::from(LOG_FORMAT_JSON), ocr_lang, opt_passwd); + let convert_options = common::ConvertOptions::new(container_image_name, common::LOG_FORMAT_JSON.to_string(), ocr_lang, opt_passwd); match container::convert(src_path_copy, output_filename, convert_options, tx, trans.clone_box()) { - Ok(_) => None, - Err(ex) => Some(format!("{}", ex)) + Ok(_) => None, + Err(ex) => Some(ex.to_string()) } }); // Rendering a progressbar in plain mode - if log_format == LOG_FORMAT_PLAIN.to_string() { + if log_format == LOG_FORMAT_PLAIN { let pb = ProgressBar::new(100); + for line in rx { let log_msg_ret: serde_json::Result = serde_json::from_slice(line.as_bytes()); @@ -215,7 +216,7 @@ fn main() -> Result<(), Box> { let exit_code = { match exec_handle.join() { Ok(exec_result) => match exec_result { - None => 0, + None => 0, Some(_) => 1 }, _ => 1 diff --git a/entrusted_client/src/main_gui.rs b/entrusted_client/src/main_gui.rs index 77af245..27525ef 100644 --- a/entrusted_client/src/main_gui.rs +++ b/entrusted_client/src/main_gui.rs @@ -26,7 +26,8 @@ mod container; const WIDGET_GAP: i32 = 20; const ELLIPSIS: &str = "..."; -const ICON_SAVE: &[u8] = include_bytes!("../../images/Save_icon.png"); +const ICON_HELP_TEXT: &str = "?"; +const ICON_SAVE: &[u8] = include_bytes!("../../images/Save_icon.png"); const ICON_FRAME: &[u8] = include_bytes!("../../images/Entrusted_icon.png"); const ICON_PASSWORD: &[u8] = include_bytes!("../../images/Password_icon.png"); @@ -832,13 +833,13 @@ fn main() -> Result<(), Box> { helpinfo_frame.draw({ move |wid| { - let (w, h) = draw::measure("H", true); + let (w, h) = draw::measure(ICON_HELP_TEXT, true); let widx = wid.x() + wid.w() - WIDGET_GAP; let widy = wid.y() + 2; let old_color = draw::get_color(); draw::draw_rect_fill(widx, widy, WIDGET_GAP, WIDGET_GAP, enums::Color::Blue); draw::set_draw_color(enums::Color::White); - draw::draw_text("H", (widx + WIDGET_GAP/2) - w/2, wid.y() + h); + draw::draw_text(ICON_HELP_TEXT, (widx + WIDGET_GAP/2) - w/2, wid.y() + h); draw::set_draw_color(old_color); } }); @@ -1487,7 +1488,7 @@ fn main() -> Result<(), Box> { let opt_passwd_value = opt_passwd.to_owned(); let convert_options = common::ConvertOptions::new( active_ociimage_option, - String::from("json"), + common::LOG_FORMAT_JSON.to_string(), active_ocrlang_option, opt_passwd_value); @@ -1883,7 +1884,7 @@ fn main() -> Result<(), Box> { let mut messages_frame_ref = messages_frame.clone(); move |w, ev| match ev { - enums::Event::Move => { + enums::Event::Move => { w.redraw(); true }, diff --git a/entrusted_client/translations/en/LC_MESSAGES/messages.po b/entrusted_client/translations/en/LC_MESSAGES/messages.po index 2a708ef..e72e6d5 100644 --- a/entrusted_client/translations/en/LC_MESSAGES/messages.po +++ b/entrusted_client/translations/en/LC_MESSAGES/messages.po @@ -246,7 +246,7 @@ msgstr "" msgid "Please install Docker or Lima." msgstr "" -msgid "Please install Podman." +msgid "Please install Docker or Podman." msgstr "" msgid "Unknown language code for the ocr-lang parameter: {0}. Hint: Try 'eng' for English." diff --git a/entrusted_client/translations/fr/LC_MESSAGES/messages.po b/entrusted_client/translations/fr/LC_MESSAGES/messages.po index 328fff5..312ad83 100644 --- a/entrusted_client/translations/fr/LC_MESSAGES/messages.po +++ b/entrusted_client/translations/fr/LC_MESSAGES/messages.po @@ -254,8 +254,8 @@ msgstr "Veuillez installer Docker." msgid "Please install Docker or Lima." msgstr "Veuillez installer Docker ou Lima." -msgid "Please install Podman." -msgstr "Veuillez installer Podman." +msgid "Please install Docker or Podman." +msgstr "Veuillez installer Docker ou Podman." msgid "Unknown language code for the ocr-lang parameter: {0}. Hint: Try 'eng' for English." msgstr "Code de langue inconnu pour le paramètre ocr-lang: {0}. Astuce: Essayez 'eng' pour l'Anglais." diff --git a/entrusted_client/translations/messages.pot b/entrusted_client/translations/messages.pot index 8d2bfbf..8f137a9 100644 --- a/entrusted_client/translations/messages.pot +++ b/entrusted_client/translations/messages.pot @@ -256,7 +256,7 @@ msgstr "" msgid "Please install Docker or Lima." msgstr "" -msgid "Please install Podman." +msgid "Please install Docker or Podman." msgstr "" msgid "Unknown language code for the ocr-lang parameter: {0}. Hint: Try 'eng' for English." diff --git a/entrusted_container/README.org b/entrusted_container/README.org index 20b1ec7..704235d 100644 --- a/entrusted_container/README.org +++ b/entrusted_container/README.org @@ -22,18 +22,21 @@ Because of a shared library, you must build the container image from the =entrus #+begin_src sh podman build -t localhost/entrusted_container . -f entrusted_container/Dockerfile + podman image prune -f --filter label=stage=entrusted_container_builder #+end_src ** Docker #+begin_src sh docker build -t localhost/entrusted_container . -f entrusted_container/Dockerfile + docker image prune -f --filter label=stage=entrusted_container_builder #+end_src ** Lima #+begin_src sh lima nerdctl build -t localhost/entrusted_container . -f entrusted_container/Dockerfile + lima nerdctl prune -f --filter label=stage=entrusted_container_builder #+end_src For "manual testing" purposes, the following dependencies are required under =Void Linux=: @@ -65,7 +68,6 @@ For all the command to follow, it is assumed that you're at the root of the =ent podman logout docker.io #+end_src - * How to run this? -This application is leveraged by the =entrusted-client= program (shell commands to =podman= or =docker= or =lima=) , it's not really meant to be used "directly" (except for dev/testing purposes). +This application is leveraged by the =entrusted-client= program (shell commands to =podman= or =docker= or =lima=) , it's not really meant to be used "directly" (except for "informed & resourceful" devs). diff --git a/entrusted_container/src/main.rs b/entrusted_container/src/main.rs index 6ba4820..16caef9 100644 --- a/entrusted_container/src/main.rs +++ b/entrusted_container/src/main.rs @@ -422,7 +422,7 @@ fn input_as_pdf_to_pathbuf_uri(logger: &Box, _: ProgressRa let mut office = Office::new(LOCATION_LIBREOFFICE_PROGRAM)?; let input_uri = urls::local_into_abs(&new_input_path.display().to_string())?; - let password_was_set =AtomicBool::new(false); + let password_was_set = AtomicBool::new(false); let failed_password_input = Arc::new(AtomicBool::new(false)); if let Some(passwd) = opt_passwd { diff --git a/entrusted_webserver/src/server.rs b/entrusted_webserver/src/server.rs index 4da897d..33b72f4 100644 --- a/entrusted_webserver/src/server.rs +++ b/entrusted_webserver/src/server.rs @@ -41,7 +41,7 @@ use crate::config; use crate::model; use crate::uil10n; -const SPA_INDEX_HTML: &str = include_str!("../web-assets/index.html"); +const SPA_INDEX_HTML: &[u8] = include_bytes!("../web-assets/index.html"); static NOTIFICATIONS_PER_REFID: Lazy>>>>> = Lazy::new(|| { Mutex::new(HashMap::>>>::new()) @@ -235,12 +235,9 @@ async fn uitranslations(req: HttpRequest) -> impl Responder { } async fn index() -> impl Responder { - let app_version = option_env!("CARGO_PKG_VERSION").unwrap_or("Unknown"); - let html_data = SPA_INDEX_HTML.replace("_APPVERSION_", app_version); - HttpResponse::Ok() .append_header((header::CONTENT_TYPE, "text/html")) - .body(html_data) + .body(SPA_INDEX_HTML) } async fn downloads(info: actix_web::web::Path, req: HttpRequest, l10n: Data>>) -> impl Responder { diff --git a/entrusted_webserver/web-assets/index.html b/entrusted_webserver/web-assets/index.html index d123fa8..a4000f2 100644 --- a/entrusted_webserver/web-assets/index.html +++ b/entrusted_webserver/web-assets/index.html @@ -12,7 +12,7 @@ - Entrusted Web _APPVERSION_ + Entrusted 0.2.1