Skip to content

Commit

Permalink
style: 📄 Add license header to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Apr 11, 2024
1 parent 6ac5b00 commit 7f71245
Show file tree
Hide file tree
Showing 47 changed files with 104 additions and 7 deletions.
1 change: 1 addition & 0 deletions .licensesnip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[workspace]
members = [
"crates/rsjudge-grpc",
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

# Use the official Rust image as the base image
FROM rust:latest AS builder

Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

version: v1
directories:
- crates/rsjudge-grpc/proto
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

#[path = "src/cli.rs"]
mod cli;

Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "rsjudge-grpc"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

version: v1
deps:
- buf.build/googleapis/googleapis
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/src/proto.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::match_single_binding)]
use tonic::include_proto;

Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-grpc/src/server.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-judger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "rsjudge-judger"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-judger/src/comparer/default_comparer.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-judger/src/comparer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

pub mod default_comparer;

use std::io;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-judger/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))]

pub mod comparer;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-rest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "rsjudge-rest"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-rest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::{io, net::SocketAddr};

use axum::{routing::get, Router};
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "rsjudge-runner"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/examples/demo.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::process::Command;

use anyhow::anyhow;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/examples/exploit.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::{path::PathBuf, process::Command};

use caps::{read, CapSet, Capability};
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/examples/exploit_inner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use caps::{read, CapSet};
use nix::unistd::{setuid, Uid};

Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/examples/normal.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use caps::{read, CapSet};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/src/caps_check.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use caps::{has_cap, raise, Capability};

use crate::error::{Error, Result};
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use caps::{errors::CapsError, Capability};
use thiserror::Error;

Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/src/user.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-runner/src/user_macro.rs
Original file line number Diff line number Diff line change
@@ -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);* $(;)?) => {
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "rsjudge-utils"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

//! Functions for working with [`std::process::Command`].
use std::{
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/src/error_macros.rs
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/src/trim.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 4 additions & 4 deletions crates/rsjudge-utils/tests/logging_on_non_result.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> tests/logging_on_non_result.test:19:27
--> tests/logging_on_non_result.test:21:27
|
19 | let _ = log_if_error!(S);
21 | let _ = log_if_error!(S);
| --------------^-
| | |
| | expected `Result<_, _>`, found `S`
Expand All @@ -16,7 +16,7 @@ note: method defined here
| ^^^^^^^
help: try wrapping the expression in a variant of `Result`
|
19 | let _ = log_if_error!(Ok(S));
21 | let _ = log_if_error!(Ok(S));
| +++ +
19 | let _ = log_if_error!(Err(S));
21 | let _ = log_if_error!(Err(S));
| ++++ +
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/tests/logging_on_non_result.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::fmt::Display;

use rsjudge_utils::log_if_error;
Expand Down
2 changes: 2 additions & 0 deletions crates/rsjudge-utils/tests/macro_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use trybuild::TestCases;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[graph]
targets = [
"x86_64-unknown-linux-gnu",
Expand Down
4 changes: 3 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"newLineKind": "auto",
"json": {},
"json": {
"trailingCommas": "never"
},
"markdown": {},
"toml": {
"indentWidth": 4
Expand Down
11 changes: 11 additions & 0 deletions licensesnip.config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"use_gitignore": true,
"file_types": {
"rs": {
"before_line": "// "
},
"yaml,yml,toml": {
"before_line": "# "
}
}
}
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

edition = "2021"
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
Expand Down
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::path::PathBuf;

use clap::Parser;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::print_stderr))]

use log::error;
Expand Down
2 changes: 2 additions & 0 deletions templates/executors.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[bash]
execute = "/usr/bin/bash -r --no-profile --no-rc {src_file}"

Expand Down
1 change: 1 addition & 0 deletions templates/server.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

[package]
name = "xtask"
version.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::{env::set_current_dir, path::Path};

use clap::{Parser, ValueEnum};
Expand Down

0 comments on commit 7f71245

Please sign in to comment.