Skip to content

Commit 0610fc0

Browse files
authored
v0.2.4: Add Security Checks: cargo-audit & cargo-deny (GitHub actions) and pre-commit hooks (#2)
Add `audit.yml` GitHub action, modify `ci.yml`, add `.pre-commit-config.yaml`
1 parent 546b059 commit 0610fc0

File tree

9 files changed

+472
-40
lines changed

9 files changed

+472
-40
lines changed

.cargo/audit.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[advisories]
2+
ignore = [
3+
# Warning: unmaintained
4+
# Title: paste - no longer maintained
5+
"RUSTSEC-2024-0436",
6+
]
7+
8+
[output]
9+
quiet = false
10+
deny = ["warnings", "unmaintained"]

.github/workflows/audit.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Security audit
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/Cargo.lock"
7+
- "**/Cargo.toml"
8+
- "**/deny.toml"
9+
pull_request:
10+
types: [ opened, reopened, synchronize ]
11+
branches:
12+
- main
13+
# schedule:
14+
# - cron: "0 0 * * *"
15+
16+
jobs:
17+
18+
audit-check:
19+
name: Audit check
20+
runs-on: ubuntu-latest
21+
permissions:
22+
issues: write
23+
checks: write
24+
steps:
25+
- uses: actions/checkout@v5
26+
- uses: rustsec/audit-check@v2.0.0
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
cargo-deny:
31+
name: Cargo deny
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v5
35+
- uses: EmbarkStudios/cargo-deny-action@v2
36+
with:
37+
rust-version: "1.89.0"
38+
log-level: warn
39+
command: check
40+
arguments: --all-features
41+
42+
audit-success:
43+
name: Audit success
44+
runs-on: ubuntu-latest
45+
needs: [audit-check, cargo-deny]
46+
steps:
47+
- run: echo "All audit jobs successfully finished."

.github/workflows/ci.yml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- "*"
57
pull_request:
68
types: [ opened, reopened, synchronize ]
79
branches:
@@ -18,26 +20,18 @@ permissions:
1820
# Each job runs in a runner environment specified by `runs-on`.
1921
jobs:
2022

21-
test:
22-
name: Test
23+
clippy:
24+
name: Clippy
2325
runs-on: ubuntu-latest
2426
steps:
27+
- uses: actions/checkout@v5
2528
- uses: ilammy/setup-nasm@v1
26-
27-
- name: Check out repository code
28-
uses: actions/checkout@v5
29-
30-
# This GitHub Action installs a Rust toolchain using "rustup".
31-
# It is designed for one-line concise usage and good defaults.
32-
- name: Install the Rust toolchain
33-
uses: dtolnay/rust-toolchain@stable
34-
35-
# A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.
36-
- name: Rust Cache Action
37-
uses: Swatinem/rust-cache@v2
38-
39-
- name: Run tests
40-
run: cargo test
29+
- uses: dtolnay/rust-toolchain@stable
30+
with:
31+
components: clippy
32+
- uses: Swatinem/rust-cache@v2
33+
- name: Linting
34+
run: cargo clippy --all-targets --all-features -- -D warnings
4135

4236
fmt:
4337
name: Format
@@ -47,18 +41,60 @@ jobs:
4741
- uses: dtolnay/rust-toolchain@stable
4842
with:
4943
components: rustfmt
44+
- uses: Swatinem/rust-cache@v2
5045
- name: Enforce formatting
51-
run: cargo fmt --check
46+
run: cargo fmt --all -- --check --color always
5247

53-
clippy:
54-
name: Clippy
48+
msrv:
49+
name: MSRV check
5550
runs-on: ubuntu-latest
5651
steps:
5752
- uses: actions/checkout@v5
5853
- uses: ilammy/setup-nasm@v1
59-
- uses: dtolnay/rust-toolchain@stable
54+
- uses: dtolnay/rust-toolchain@master
6055
with:
56+
toolchain: 1.89.0
6157
components: clippy
58+
- run: cargo fetch
59+
- name: MSRV check with cargo clippy
60+
run: cargo clippy --all-targets --all-features -- -D warnings
61+
62+
publish-check:
63+
name: Publish check
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v5
67+
- uses: ilammy/setup-nasm@v1
68+
- uses: dtolnay/rust-toolchain@stable
6269
- uses: Swatinem/rust-cache@v2
63-
- name: Linting
64-
run: cargo clippy -- -D warnings
70+
- run: cargo fetch
71+
- name: cargo publish dry run
72+
run: cargo publish --dry-run
73+
74+
test:
75+
name: Test
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Check out repository code
79+
uses: actions/checkout@v5
80+
81+
- uses: ilammy/setup-nasm@v1
82+
83+
# This GitHub Action installs a Rust toolchain using "rustup".
84+
# It is designed for one-line concise usage and good defaults.
85+
- name: Install the Rust toolchain
86+
uses: dtolnay/rust-toolchain@stable
87+
88+
# A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.
89+
- name: Rust Cache Action
90+
uses: Swatinem/rust-cache@v2
91+
92+
- name: Run tests
93+
run: cargo test --all --all-targets
94+
95+
ci-success:
96+
name: CI success
97+
runs-on: ubuntu-latest
98+
needs: [clippy, fmt, msrv, publish-check, test]
99+
steps:
100+
- run: echo "All CI jobs successfully finished."

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
repos:
2+
3+
- repo: local
4+
hooks:
5+
- id: check
6+
name: check
7+
description: Standard check
8+
entry: cargo check
9+
language: system
10+
types: [ rust ]
11+
pass_filenames: false
12+
13+
- id: clippy
14+
name: clippy
15+
description: More rigorous check
16+
entry: cargo clippy --all-targets --all-features -- -D warnings
17+
language: rust
18+
pass_filenames: false
19+
20+
- id: rustfmt
21+
name: rustfmt
22+
description: Check if all files follow the rustfmt style
23+
entry: cargo fmt --all -- --check --color always
24+
language: rust
25+
types: [ rust ]
26+
pass_filenames: false
27+
28+
- id: test
29+
name: test
30+
description: Run tests
31+
entry: cargo test --all --all-targets
32+
language: rust
33+
types: [ rust ]
34+
pass_filenames: false
35+
36+
- repo: https://github.com/EmbarkStudios/cargo-deny
37+
rev: 0.18.5
38+
hooks:
39+
- id: cargo-deny
40+
args: ["--all-features", "check"]
41+
42+
- repo: https://github.com/pre-commit/pre-commit-hooks
43+
rev: v6.0.0
44+
hooks:
45+
- id: check-added-large-files
46+
- id: check-yaml
47+
- id: end-of-file-fixer

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Some form of concurrent execution, but this might not be necessary as some
1111
dependencies already use `rayon` and `crossbeam`.
1212

13-
## [0.2.4] - 2025-09-08
13+
## [0.2.4] - 2025-09-30
14+
15+
### Added
16+
17+
- GitHub action `audit.yml`, with `audit-check` and `cargo-deny-action` actions
18+
- `audit.toml` for local and CI `cargo audit` configuration
19+
- `deny.toml` for local and CI `cargo deny` configuration
20+
- Pre-commit hooks, `.pre-commit-config.yaml`
1421

1522
### Changed
1623
- Updated several dependencies to newer versions.
1724
- `cargo audit` found a security vulnerability in a dependency (that version has been yanked).
25+
- The build process for the release profile now uses the LTO optimization.
1826

1927
## [0.2.3] - 2024-07-10
2028

Cargo.lock

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

Cargo.toml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
[package]
22
name = "reduce_image_size"
3+
description = "Reduces size of images in a folder (and optionally sub-folders, recursively)."
34
version = "0.2.4"
4-
edition = "2024"
55
authors = ["Ivan Lazarević"]
6-
description = "Reduces size of images in a folder (and optionally sub-folders, recursively)."
76
repository = "https://github.com/ivanbgd/reduce-image-size-rust"
87
license = "MIT"
9-
keywords = ["image", "images", "photo", "jpeg", "png"]
8+
readme = "README.md"
109
categories = ["computer-vision", "multimedia", "multimedia::images", "command-line-utilities"]
11-
12-
[profile.release]
13-
strip = "symbols"
10+
keywords = ["image", "images", "photo", "jpeg", "png"]
11+
edition = "2024"
12+
rust-version = "1.89.0"
1413

1514
[lib]
1615
path = "src/lib.rs"
@@ -20,10 +19,18 @@ name = "reduce_image_size"
2019
path = "src/main.rs"
2120

2221
[dependencies]
23-
clap = { version = "4.5.9", features = ["derive"] }
22+
clap = { version = "4.5.48", features = ["derive"] }
2423
fast_image_resize = { version = "5.3.0" }
2524
image = "0.25.8"
26-
oxipng = { version = "9.1.1", default-features = false, features = ["parallel"] }
27-
pathdiff = { version = "0.2.1" }
28-
turbojpeg = { version = "1.1.0", features = ["image"] }
25+
oxipng = { version = "9.1.5", default-features = false, features = ["parallel"] }
26+
pathdiff = { version = "0.2.3" }
27+
turbojpeg = { version = "1.3.3", features = ["image"] }
2928
walkdir = "2.5.0"
29+
30+
[profile.dev.package.oxipng]
31+
opt-level = 3
32+
33+
[profile.release]
34+
strip = "symbols"
35+
lto = "fat"
36+
codegen-units = 1

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Reduce Image Size
22

3-
[![CI](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/ci.yml)
3+
[![license](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](LICENSE)
44
[![Crates.io](https://img.shields.io/crates/v/reduce_image_size.svg)](https://crates.io/crates/reduce_image_size)
55
[![docs.rs](https://docs.rs/reduce_image_size/badge.svg)](https://docs.rs/reduce_image_size/)
6+
[![CI](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/ci.yml)
7+
[![Security audit](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/audit.yml/badge.svg)](https://github.com/ivanbgd/reduce-image-size-rust/actions/workflows/audit.yml)
8+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
69

710
## Description
811
Reduces size of images in a folder (and optionally sub-folders, recursively).
@@ -57,13 +60,37 @@ The file paths in the examples are for Windows.
5760
- `reduce_image_size D:\img_src D:\img_dst --recursive --resize --quality 60 --size L`
5861

5962
## Notes
60-
- Updated and tested in Rust 1.89.0 on Apple silicon with macOS Sequoia 15.3.
63+
- Updated and tested in Rust 1.89.0 and 1.90.0 on Apple silicon with macOS Sequoia 15.3.2.
6164
- First developed in Rust 1.74.1, but also tested later with Rust 1.79.0.
6265
- Tested on x86-64 CPUs on Windows 10 and Windows 11.
6366
- Tested on Apple silicon, M2 Pro, on macOS Sonoma 14.5.
6467
- Also tested on WSL - Ubuntu 22.04.2 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64) on Windows 11 @ x86-64.
6568
- Linux wasn't tested directly, but should work, at least on x86-64 CPUs.
6669

70+
## Security
71+
72+
- [cargo audit](https://github.com/rustsec/rustsec/blob/main/cargo-audit/README.md) is supported,
73+
as well as its GitHub action, [audit-check](https://github.com/rustsec/audit-check).
74+
- [cargo deny](https://embarkstudios.github.io/cargo-deny/) is supported,
75+
as well as its GitHub action, [cargo-deny-action](https://github.com/EmbarkStudios/cargo-deny-action).
76+
77+
## Development
78+
79+
### Pre-commit
80+
81+
[pre-commit](https://pre-commit.com/) hooks are supported.
82+
83+
```shell
84+
$ pip install pre-commit # If you don't already have pre-commit installed on your machine. Run once.
85+
$ pre-commit autoupdate # Update hook repositories to the latest versions.
86+
$ pre-commit install # Sets up the pre-commit git hook script for the repository. Run once.
87+
$ pre-commit install --hook-type pre-push # Sets up the pre-push git hook script for the repository. Run once.
88+
$ pre-commit run # For manual running; considers only modified files.
89+
$ pre-commit run --all-files # For manual running; considers all files.
90+
```
91+
92+
After installing it, the provided [pre-commit hook(s)](.pre-commit-config.yaml) will run automatically on `git commit`.
93+
6794
## Running the Application
6895
Executable files for Windows, macOS and Linux can be downloaded from
6996
the [Releases](https://github.com/ivanbgd/reduce-image-size-rust/releases) page of the repository.

0 commit comments

Comments
 (0)