diff --git a/.licensesnip b/.licensesnip new file mode 100644 index 0000000..1abba28 --- /dev/null +++ b/.licensesnip @@ -0,0 +1 @@ +SPDX-License-Identifier: Apache-2.0 diff --git a/Cargo.toml b/Cargo.toml index a2a91f6..03d23f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [workspace] members = [ "crates/rsjudge-grpc", diff --git a/Dockerfile b/Dockerfile index dec34d6..6e72b9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + # Use the official Rust image as the base image FROM rust:latest AS builder diff --git a/README.adoc b/README.adoc index 9dd3085..a5f32aa 100644 --- a/README.adoc +++ b/README.adoc @@ -3,7 +3,7 @@ image:assets/rsjudge.svg[Rsjudge logo] -An online judge sandbox server in Rust, inspired by https://github.com/criyle/go-judge[go-judge], for [SAST OJ]. +An online judge sandbox server in Rust, inspired by https://github.com/criyle/go-judge[go-judge], for SAST OJ. == Features diff --git a/buf.work.yaml b/buf.work.yaml index 0b7a593..707237d 100644 --- a/buf.work.yaml +++ b/buf.work.yaml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + version: v1 directories: - crates/rsjudge-grpc/proto diff --git a/build.rs b/build.rs index fdade80..b9f42df 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #[path = "src/cli.rs"] mod cli; diff --git a/crates/rsjudge-grpc/Cargo.toml b/crates/rsjudge-grpc/Cargo.toml index cd48f8f..54a3441 100644 --- a/crates/rsjudge-grpc/Cargo.toml +++ b/crates/rsjudge-grpc/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "rsjudge-grpc" version.workspace = true diff --git a/crates/rsjudge-grpc/build.rs b/crates/rsjudge-grpc/build.rs index 2ebf0cd..35c832c 100644 --- a/crates/rsjudge-grpc/build.rs +++ b/crates/rsjudge-grpc/build.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::{env, io::BufRead, path::PathBuf, process::Command}; use rsjudge_utils::command::check_output; diff --git a/crates/rsjudge-grpc/proto/buf.yaml b/crates/rsjudge-grpc/proto/buf.yaml index 6c57cb8..1e857d8 100644 --- a/crates/rsjudge-grpc/proto/buf.yaml +++ b/crates/rsjudge-grpc/proto/buf.yaml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + version: v1 deps: - buf.build/googleapis/googleapis diff --git a/crates/rsjudge-grpc/src/lib.rs b/crates/rsjudge-grpc/src/lib.rs index 0259d2d..df4f334 100644 --- a/crates/rsjudge-grpc/src/lib.rs +++ b/crates/rsjudge-grpc/src/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] use std::net::SocketAddr; diff --git a/crates/rsjudge-grpc/src/proto.rs b/crates/rsjudge-grpc/src/proto.rs index c80bd13..6d6d79c 100644 --- a/crates/rsjudge-grpc/src/proto.rs +++ b/crates/rsjudge-grpc/src/proto.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #![allow(clippy::match_single_binding)] use tonic::include_proto; diff --git a/crates/rsjudge-grpc/src/server.rs b/crates/rsjudge-grpc/src/server.rs index 6274d49..f4fb343 100644 --- a/crates/rsjudge-grpc/src/server.rs +++ b/crates/rsjudge-grpc/src/server.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use log::debug; use tokio_stream::wrappers::ReceiverStream; use tonic::{async_trait, Request, Response, Status}; diff --git a/crates/rsjudge-judger/Cargo.toml b/crates/rsjudge-judger/Cargo.toml index 8e0c992..06b5d7a 100644 --- a/crates/rsjudge-judger/Cargo.toml +++ b/crates/rsjudge-judger/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "rsjudge-judger" version.workspace = true diff --git a/crates/rsjudge-judger/src/comparer/default_comparer.rs b/crates/rsjudge-judger/src/comparer/default_comparer.rs index d722c12..389f7c8 100644 --- a/crates/rsjudge-judger/src/comparer/default_comparer.rs +++ b/crates/rsjudge-judger/src/comparer/default_comparer.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! A default comparer implementation, supporting ignoring trailing whitespace and/or trailing newline. use std::io; diff --git a/crates/rsjudge-judger/src/comparer/mod.rs b/crates/rsjudge-judger/src/comparer/mod.rs index 9376842..12c8b7a 100644 --- a/crates/rsjudge-judger/src/comparer/mod.rs +++ b/crates/rsjudge-judger/src/comparer/mod.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + pub mod default_comparer; use std::io; diff --git a/crates/rsjudge-judger/src/lib.rs b/crates/rsjudge-judger/src/lib.rs index 36d6c36..6fbdb5a 100644 --- a/crates/rsjudge-judger/src/lib.rs +++ b/crates/rsjudge-judger/src/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] pub mod comparer; diff --git a/crates/rsjudge-rest/Cargo.toml b/crates/rsjudge-rest/Cargo.toml index 2fb226c..27d2dbf 100644 --- a/crates/rsjudge-rest/Cargo.toml +++ b/crates/rsjudge-rest/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "rsjudge-rest" version.workspace = true diff --git a/crates/rsjudge-rest/src/lib.rs b/crates/rsjudge-rest/src/lib.rs index 059fd0d..fb57c9d 100644 --- a/crates/rsjudge-rest/src/lib.rs +++ b/crates/rsjudge-rest/src/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::{io, net::SocketAddr}; use axum::{routing::get, Router}; diff --git a/crates/rsjudge-runner/Cargo.toml b/crates/rsjudge-runner/Cargo.toml index 064c3fa..8e5f689 100644 --- a/crates/rsjudge-runner/Cargo.toml +++ b/crates/rsjudge-runner/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "rsjudge-runner" version.workspace = true diff --git a/crates/rsjudge-runner/examples/demo.rs b/crates/rsjudge-runner/examples/demo.rs index 2811ce6..c26fd9a 100644 --- a/crates/rsjudge-runner/examples/demo.rs +++ b/crates/rsjudge-runner/examples/demo.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::process::Command; use anyhow::anyhow; diff --git a/crates/rsjudge-runner/examples/exploit.rs b/crates/rsjudge-runner/examples/exploit.rs index ac3ac74..eea65d2 100644 --- a/crates/rsjudge-runner/examples/exploit.rs +++ b/crates/rsjudge-runner/examples/exploit.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::{path::PathBuf, process::Command}; use caps::{read, CapSet, Capability}; diff --git a/crates/rsjudge-runner/examples/exploit_inner.rs b/crates/rsjudge-runner/examples/exploit_inner.rs index 9f8e8b9..f7e2bff 100644 --- a/crates/rsjudge-runner/examples/exploit_inner.rs +++ b/crates/rsjudge-runner/examples/exploit_inner.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use caps::{read, CapSet}; use nix::unistd::{setuid, Uid}; diff --git a/crates/rsjudge-runner/examples/normal.rs b/crates/rsjudge-runner/examples/normal.rs index ca75700..5ef792e 100644 --- a/crates/rsjudge-runner/examples/normal.rs +++ b/crates/rsjudge-runner/examples/normal.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use caps::{read, CapSet}; fn main() { diff --git a/crates/rsjudge-runner/src/caps_check.rs b/crates/rsjudge-runner/src/caps_check.rs index 11f70b0..4ac59af 100644 --- a/crates/rsjudge-runner/src/caps_check.rs +++ b/crates/rsjudge-runner/src/caps_check.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use caps::{has_cap, raise, Capability}; use crate::error::{Error, Result}; diff --git a/crates/rsjudge-runner/src/error.rs b/crates/rsjudge-runner/src/error.rs index f01e168..9f75ae8 100644 --- a/crates/rsjudge-runner/src/error.rs +++ b/crates/rsjudge-runner/src/error.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use caps::{errors::CapsError, Capability}; use thiserror::Error; diff --git a/crates/rsjudge-runner/src/lib.rs b/crates/rsjudge-runner/src/lib.rs index 00ad559..7ab5ff0 100644 --- a/crates/rsjudge-runner/src/lib.rs +++ b/crates/rsjudge-runner/src/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] use std::{os::unix::process::CommandExt as _, process::Command}; diff --git a/crates/rsjudge-runner/src/user.rs b/crates/rsjudge-runner/src/user.rs index da2899e..ef6e98e 100644 --- a/crates/rsjudge-runner/src/user.rs +++ b/crates/rsjudge-runner/src/user.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! Functions to get user instances. //! //! All functions return a reference to a static instance of [`uzers::User`] if succeeded. diff --git a/crates/rsjudge-runner/src/user_macro.rs b/crates/rsjudge-runner/src/user_macro.rs index 059f1a9..9131f98 100644 --- a/crates/rsjudge-runner/src/user_macro.rs +++ b/crates/rsjudge-runner/src/user_macro.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + /// Generate functions to get user instances. macro_rules! users { ($($vis:vis fn $id:ident() => $name:literal);* $(;)?) => { diff --git a/crates/rsjudge-utils/Cargo.toml b/crates/rsjudge-utils/Cargo.toml index a0c26a5..c323b6b 100644 --- a/crates/rsjudge-utils/Cargo.toml +++ b/crates/rsjudge-utils/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "rsjudge-utils" version.workspace = true diff --git a/crates/rsjudge-utils/src/command.rs b/crates/rsjudge-utils/src/command.rs index 8a43a0d..f3a1111 100644 --- a/crates/rsjudge-utils/src/command.rs +++ b/crates/rsjudge-utils/src/command.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! Functions for working with [`std::process::Command`]. use std::{ diff --git a/crates/rsjudge-utils/src/error_macros.rs b/crates/rsjudge-utils/src/error_macros.rs index fbec4d2..c3fd909 100644 --- a/crates/rsjudge-utils/src/error_macros.rs +++ b/crates/rsjudge-utils/src/error_macros.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! Macro for logging when error occurs. /// Log an error message and return an `Err` variant of `Result`. diff --git a/crates/rsjudge-utils/src/lib.rs b/crates/rsjudge-utils/src/lib.rs index 4b1187e..6a73ca2 100644 --- a/crates/rsjudge-utils/src/lib.rs +++ b/crates/rsjudge-utils/src/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! A collection of utility functions for the rsjudge project. // No `(e)print` or `(e)println` in library code. diff --git a/crates/rsjudge-utils/src/trim.rs b/crates/rsjudge-utils/src/trim.rs index f603403..d3bf002 100644 --- a/crates/rsjudge-utils/src/trim.rs +++ b/crates/rsjudge-utils/src/trim.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + //! Functions for trimming ASCII whitespace from `[u8]` and `str`. /// Returns a byte slice with leading ASCII whitespace bytes removed. diff --git a/crates/rsjudge-utils/tests/logging_on_non_result.test b/crates/rsjudge-utils/tests/logging_on_non_result.test index 52d8b81..a6f77f2 100644 --- a/crates/rsjudge-utils/tests/logging_on_non_result.test +++ b/crates/rsjudge-utils/tests/logging_on_non_result.test @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::fmt::Display; use rsjudge_utils::log_if_error; diff --git a/crates/rsjudge-utils/tests/macro_test.rs b/crates/rsjudge-utils/tests/macro_test.rs index 6ca4596..5211c58 100644 --- a/crates/rsjudge-utils/tests/macro_test.rs +++ b/crates/rsjudge-utils/tests/macro_test.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use trybuild::TestCases; #[test] diff --git a/deny.toml b/deny.toml index e669b66..a5c2597 100644 --- a/deny.toml +++ b/deny.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [graph] targets = [ "x86_64-unknown-linux-gnu", diff --git a/dprint.json b/dprint.json index 0b12c00..1a74ebc 100644 --- a/dprint.json +++ b/dprint.json @@ -1,6 +1,8 @@ { "newLineKind": "auto", - "json": {}, + "json": { + "trailingCommas": "never" + }, "markdown": {}, "toml": { "indentWidth": 4 diff --git a/licensesnip.config.jsonc b/licensesnip.config.jsonc new file mode 100644 index 0000000..837eeb4 --- /dev/null +++ b/licensesnip.config.jsonc @@ -0,0 +1,11 @@ +{ + "use_gitignore": true, + "file_types": { + "rs": { + "before_line": "// " + }, + "yaml,yml,toml": { + "before_line": "# " + } + } +} diff --git a/rustfmt.toml b/rustfmt.toml index c92b953..4c149f1 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + edition = "2021" group_imports = "StdExternalCrate" imports_granularity = "Crate" diff --git a/src/cli.rs b/src/cli.rs index 685ec71..2e9e072 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::path::PathBuf; use clap::Parser; diff --git a/src/lib.rs b/src/lib.rs index 80953d2..63ced2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 + #![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] #![doc(html_logo_url = "https://cdn.jsdelivr.net/gh/NJUPT-SAST/rsjudge@main/assets/rsjudge.svg")] //! An online judge sandbox server in Rust, -//! inspired by https://github.com/criyle/go-judge[go-judge], for [SAST OJ]. +//! inspired by [go-judge](https://github.com/criyle/go-judge), for SAST OJ. use std::process::Command; diff --git a/src/main.rs b/src/main.rs index a08e648..6b7384c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + #![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))] use log::error; diff --git a/templates/executors.toml b/templates/executors.toml index ace68ce..a3d650b 100644 --- a/templates/executors.toml +++ b/templates/executors.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [bash] execute = "/usr/bin/bash -r --no-profile --no-rc {src_file}" diff --git a/templates/server.toml b/templates/server.toml index e69de29..9881313 100644 --- a/templates/server.toml +++ b/templates/server.toml @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index bdf060c..5db1c49 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + [package] name = "xtask" version.workspace = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1cf830e..c872007 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + use std::{env::set_current_dir, path::Path}; use clap::{Parser, ValueEnum};