mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
chore: Add clippy lints (#529)
Lints are added (deny) at crate level. In each offending file, the failing lints are explicitly allowed. Each file will be fixed in subsequent PRs. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
604591a0f7
commit
249dcd0b43
2
.github/actions/toolchains/rust/action.yml
vendored
2
.github/actions/toolchains/rust/action.yml
vendored
@@ -4,7 +4,7 @@ inputs:
|
||||
toolchain:
|
||||
description: 'Rust toolchain version'
|
||||
required: false
|
||||
default: '1.89.0'
|
||||
default: '1.92.0'
|
||||
components:
|
||||
description: 'Additional components to install'
|
||||
required: false
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
**Regorus** is
|
||||
|
||||
- *Rego*-*Rus(t)* - A fast, light-weight [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/)
|
||||
interpreter written in Rust.
|
||||
interpreter written in Rust.
|
||||
- *Rigorous* - A rigorous enforcer of well-defined Rego semantics.
|
||||
|
||||
Regorus is also
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_const_for_fn, clippy::pattern_type_mismatch)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_numeric};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::as_conversions)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::BoolOp;
|
||||
use crate::value::Value;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::unseparated_literal_suffix, clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::ensure_args_count;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names, clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_string, ensure_string_collection};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_object};
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::expect_used,
|
||||
clippy::indexing_slicing,
|
||||
clippy::panic,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::unwrap_used,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::option_if_let_else,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::useless_let_if_seq
|
||||
)] // builtins perform validated indexing and intentional arithmetic/string ops
|
||||
|
||||
mod aggregates;
|
||||
mod arrays;
|
||||
mod bitwise;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::expect_used,
|
||||
clippy::needless_continue,
|
||||
clippy::unused_trait_names
|
||||
)] // net builtins panic/expect in invariant checks
|
||||
|
||||
use core::net::IpAddr;
|
||||
use ipnet::IpNet;
|
||||
use std::format;
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::ast::{ArithOp, Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_numeric};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_array, ensure_object};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::as_conversions)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::as_conversions, clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_set};
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::indexing_slicing)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_numeric, ensure_string};
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // ported Go time parsing uses intentional arithmetic and explicit suffixes
|
||||
|
||||
use crate::*;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
@@ -584,6 +590,11 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(
|
||||
clippy::unwrap_used,
|
||||
clippy::unused_trait_names,
|
||||
clippy::as_conversions
|
||||
)] // test fixtures build durations with unwrap for brevity
|
||||
use chrono::{Datelike, Month, TimeZone, Timelike, Weekday};
|
||||
use chrono_tz::PST8PDT;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT and Apache 2.0 License.
|
||||
|
||||
#![allow(clippy::as_conversions, clippy::unused_trait_names)]
|
||||
use anyhow::{anyhow, Result};
|
||||
use chrono::{DateTime, Datelike, FixedOffset, NaiveDate, Timelike};
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_string};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::indexing_slicing, clippy::pattern_type_mismatch)]
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::unused_trait_names)]
|
||||
use alloc::borrow::Cow;
|
||||
use core::str::FromStr;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::lexer::Span;
|
||||
use crate::number::Number;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::missing_const_for_fn, clippy::as_conversions)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
use crate::ast::{Expr, Ref};
|
||||
use crate::builtins;
|
||||
use crate::builtins::utils::{ensure_args_count, ensure_string};
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::redundant_pub_crate,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::option_if_let_else,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::compiler::hoist::HoistedLoopsLookup;
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::option_if_let_else,
|
||||
clippy::if_then_some_else_none,
|
||||
clippy::unused_self,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::useless_let_if_seq
|
||||
)]
|
||||
//! Compiler-related functionality for Regorus.
|
||||
//!
|
||||
//! This module contains utilities and data structures used during
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names)]
|
||||
|
||||
//! Compilation context types shared across compiler components.
|
||||
//!
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::unreachable,
|
||||
clippy::expect_used,
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
//! Assignment-specific planning utilities.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::redundant_pub_crate)]
|
||||
|
||||
//! Context traits shared across planner submodules.
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::redundant_pub_crate,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
//! Functions responsible for building destructuring plans.
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
//! Error definitions for the destructuring planner.
|
||||
|
||||
use alloc::format;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names)]
|
||||
|
||||
//! Planner helpers for function parameters and loop indices.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names, clippy::pattern_type_mismatch)]
|
||||
|
||||
//! Core data structures used by the destructuring planner.
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
//! Planner support for `some .. in` expressions.
|
||||
|
||||
use alloc::collections::BTreeSet;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::redundant_pub_crate,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
//! Shared helper routines for the destructuring planner modules.
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
//! Loop hoisting functionality for compilation.
|
||||
//!
|
||||
@@ -277,6 +283,7 @@ impl HoistedLoopsLookup {
|
||||
self.query_contexts.truncate_modules(module_count);
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn module_len(&self) -> usize {
|
||||
self.statement_loops.module_len()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::print_stderr,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::compiled_policy::CompiledPolicy;
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic_in_result_fn,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::unused_self,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
#![cfg(debug_assertions)]
|
||||
#![allow(clippy::panic)] // debug-only index checks panic on invariants
|
||||
|
||||
use crate::ast::*;
|
||||
use alloc::collections::BTreeSet;
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unwrap_used,
|
||||
clippy::unimplemented,
|
||||
clippy::panic_in_result_fn,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::useless_let_if_seq,
|
||||
clippy::option_if_let_else,
|
||||
clippy::unused_self,
|
||||
clippy::print_stderr,
|
||||
clippy::needless_continue,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::builtins::{self, BuiltinFcn};
|
||||
@@ -3432,6 +3449,7 @@ impl Interpreter {
|
||||
}
|
||||
|
||||
/// Evaluate a default rule and return the resulting value for compiler consumers.
|
||||
#[cfg(feature = "rvm")]
|
||||
pub fn eval_default_rule_for_compiler(&mut self, rule_path: &str) -> Result<Value> {
|
||||
self.input = Value::Undefined;
|
||||
self.data = Value::Undefined;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::indexing_slicing)]
|
||||
|
||||
use super::super::error::TargetCompileError;
|
||||
#[cfg(feature = "azure_policy")]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_const_for_fn)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_const_for_fn, clippy::pattern_type_mismatch)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names)]
|
||||
#![allow(missing_debug_implementations)] // parser structs are internal; Debug not required
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use alloc::string::String;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::arithmetic_side_effects, clippy::unused_trait_names)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#[cfg(test)]
|
||||
mod condition_tests {
|
||||
#![allow(clippy::panic, clippy::unwrap_used, clippy::expect_used)] // tests unwrap/expect to assert parse results
|
||||
use crate::languages::azure_rbac::parser::*;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::as_conversions)]
|
||||
|
||||
use super::{CompilationContext, Compiler, ComprehensionType, ContextType, Register, Result};
|
||||
use crate::ast::{ExprRef, Query};
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::expect_used,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names
|
||||
)]
|
||||
|
||||
use super::{CompilationContext, Compiler, CompilerError, Register, Result, Scope};
|
||||
use crate::ast::ExprRef;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
use super::Compiler;
|
||||
use super::Register;
|
||||
use crate::compiler::destructuring_planner::plans::{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::String;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names, clippy::pattern_type_mismatch)]
|
||||
|
||||
mod collection_literals;
|
||||
mod operations;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{Compiler, Register, Result};
|
||||
use crate::ast::ExprRef;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::pattern_type_mismatch)]
|
||||
|
||||
use super::{Compiler, CompilerError, Register, Result};
|
||||
use crate::ast::{ArithOp, BinOp, BoolOp, ExprRef};
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{Compiler, CompilerError, Register, Result};
|
||||
use crate::ast::ExprRef;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{CompilationContext, Compiler, CompilerError, ContextType, Register, Result};
|
||||
use crate::ast::{self, ExprRef, LiteralStmt, Query};
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
#![allow(
|
||||
missing_debug_implementations,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::option_if_let_else,
|
||||
clippy::if_then_some_else_none,
|
||||
clippy::unused_self
|
||||
)] // compiler internals do not require Debug
|
||||
|
||||
mod comprehensions;
|
||||
mod core;
|
||||
mod destructuring;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{Compiler, CompilerError, Result};
|
||||
use crate::interpreter::Interpreter;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{Compiler, CompilerError, ComprehensionType, ContextType, Result};
|
||||
use crate::ast::{self, LiteralStmt, Query};
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::expect_used,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{Compiler, CompilerError, Register, Result, WorklistEntry};
|
||||
use crate::lexer::Span;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unwrap_used,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use super::{CompilationContext, Compiler, CompilerError, ContextType, Result, WorklistEntry};
|
||||
use crate::ast::{Expr, Rule, RuleHead};
|
||||
@@ -105,12 +114,11 @@ impl<'a> Compiler<'a> {
|
||||
}
|
||||
|
||||
fn find_module_index_for_rule(&self, rule_ref: &crate::ast::NodeRef<Rule>) -> Result<u32> {
|
||||
let rule_ptr = rule_ref.as_ref() as *const Rule;
|
||||
let rule = rule_ref.as_ref();
|
||||
|
||||
for (module_idx, module) in self.policy.get_modules().iter().enumerate() {
|
||||
for policy_rule in &module.policy {
|
||||
let policy_rule_ptr = policy_rule.as_ref() as *const Rule;
|
||||
if policy_rule_ptr == rule_ptr {
|
||||
if core::ptr::eq(policy_rule.as_ref(), rule) {
|
||||
return Ok(module_idx as u32);
|
||||
}
|
||||
}
|
||||
@@ -126,12 +134,11 @@ impl<'a> Compiler<'a> {
|
||||
) -> Result<(String, u32)> {
|
||||
if let Some(rule_definitions) = rules.get(rule_path) {
|
||||
if let Some(first_rule_ref) = rule_definitions.first() {
|
||||
let rule_ptr = first_rule_ref.as_ref() as *const Rule;
|
||||
let rule = first_rule_ref.as_ref();
|
||||
|
||||
for (module_index, module) in self.policy.get_modules().iter().enumerate() {
|
||||
for policy_rule in &module.policy {
|
||||
let policy_rule_ptr = policy_rule.as_ref() as *const Rule;
|
||||
if policy_rule_ptr == rule_ptr {
|
||||
if core::ptr::eq(policy_rule.as_ref(), rule) {
|
||||
let package_path =
|
||||
match get_path_string(&module.package.refr, Some("data")) {
|
||||
Ok(path) => path,
|
||||
|
||||
12
src/lexer.rs
12
src/lexer.rs
@@ -1,5 +1,17 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::std_instead_of_core,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
#![allow(missing_debug_implementations)] // lexer types are internal
|
||||
|
||||
use crate::*;
|
||||
use core::cmp;
|
||||
|
||||
110
src/lib.rs
110
src/lib.rs
@@ -1,9 +1,104 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Unsafe code should not be used.
|
||||
// Hard to reason about correctness, and maintainability.
|
||||
#![forbid(unsafe_code)]
|
||||
// Ensure that all lint names are valid.
|
||||
#![deny(unknown_lints)]
|
||||
// Fail-fast lints: correctness, safety, and API surface
|
||||
#![deny(
|
||||
// Panic sources - catch all ways code can panic
|
||||
clippy::panic, // forbid explicit panic! macro
|
||||
clippy::unreachable, // catches unreachable! macro usage
|
||||
clippy::todo, // blocks remaining todo! placeholders
|
||||
clippy::unimplemented, // blocks unimplemented! placeholders
|
||||
clippy::unwrap_used, // reject Result/Option unwraps
|
||||
clippy::expect_used, // reject expect with panic messages
|
||||
clippy::manual_assert, // prefer assert! over manual if/panic
|
||||
clippy::indexing_slicing, // reject unchecked [] indexing
|
||||
clippy::arithmetic_side_effects, // reject overflowing/unchecked math
|
||||
clippy::panic_in_result_fn, // disallow panic inside functions returning Result
|
||||
|
||||
// Rust warnings/upstream
|
||||
dead_code, // ban unused items
|
||||
deprecated, // prevent use of deprecated APIs
|
||||
deprecated_in_future, // catch items scheduled for deprecation
|
||||
exported_private_dependencies, // avoid leaking private deps in public API
|
||||
future_incompatible, // catch patterns slated to break
|
||||
invalid_doc_attributes, // ensure doc attributes are valid
|
||||
keyword_idents, // disallow identifiers that are keywords
|
||||
macro_use_extern_crate, // block legacy macro_use extern crate
|
||||
missing_debug_implementations, // require Debug on public types
|
||||
// TODO: Address in future pass
|
||||
// missing_docs, // require docs on public items
|
||||
non_ascii_idents, // disallow non-ASCII identifiers
|
||||
nonstandard_style, // enforce idiomatic naming/style
|
||||
noop_method_call, // catch no-op method calls
|
||||
trivial_bounds, // forbid useless trait bounds
|
||||
trivial_casts, // block needless casts
|
||||
unreachable_code, // catch dead/unreachable code
|
||||
unreachable_patterns, // catch unreachable match arms
|
||||
// TODO: Address in future pass
|
||||
// unreachable_pub,
|
||||
unused_extern_crates, // remove unused extern crate declarations
|
||||
unused_import_braces, // avoid unused braces in imports
|
||||
absolute_paths_not_starting_with_crate, // enforce crate:: prefix for absolute paths
|
||||
|
||||
// Unsafe code / low-level hazards
|
||||
clippy::unseparated_literal_suffix, // enforce underscore before literal suffixes
|
||||
clippy::print_stderr, // discourage printing to stderr
|
||||
clippy::use_debug, // discourage Debug formatting in display contexts
|
||||
|
||||
// Documentation & diagnostics
|
||||
// TODO: Address in future pass
|
||||
// clippy::doc_link_with_quotes, // avoid quoted intra-doc links
|
||||
// clippy::doc_markdown, // flag bad Markdown in docs
|
||||
// clippy::missing_docs_in_private_items, // require docs on private items
|
||||
// clippy::missing_errors_doc, // require docs for error cases
|
||||
|
||||
// API correctness / style
|
||||
clippy::missing_const_for_fn, // suggest const fn where possible
|
||||
clippy::option_if_let_else, // prefer map_or/unwrap_or_else over if/let
|
||||
clippy::if_then_some_else_none, // prefer Option combinators over if/else
|
||||
clippy::semicolon_if_nothing_returned, // enforce trailing semicolon for unit
|
||||
clippy::unused_self, // remove unused self parameters
|
||||
clippy::used_underscore_binding, // avoid using bindings prefixed with _
|
||||
clippy::useless_let_if_seq, // simplify let-if sequences
|
||||
clippy::similar_names, // flag confusingly similar identifiers
|
||||
clippy::shadow_unrelated, // discourage shadowing unrelated variables
|
||||
clippy::redundant_pub_crate, // avoid pub(crate) on already pub items
|
||||
clippy::wildcard_dependencies, // disallow wildcard Cargo dependency versions
|
||||
// TODO: Address in future pass
|
||||
// clippy::wildcard_imports, // discourage glob imports
|
||||
|
||||
// Numeric correctness
|
||||
// TODO: Address in future pass
|
||||
clippy::float_cmp, // avoid exact float equality checks
|
||||
clippy::float_cmp_const, // avoid comparing floats to consts directly
|
||||
clippy::float_equality_without_abs, // require tolerance in float equality
|
||||
clippy::suspicious_operation_groupings, // catch ambiguous operator precedence
|
||||
|
||||
// no_std hygiene
|
||||
clippy::std_instead_of_core, // prefer core/alloc over std in no_std
|
||||
|
||||
// Misc polish
|
||||
clippy::dbg_macro, // forbid dbg! in production code
|
||||
clippy::debug_assert_with_mut_call, // avoid mutating inside debug_assert
|
||||
clippy::empty_line_after_outer_attr, // enforce spacing after outer attrs
|
||||
clippy::empty_structs_with_brackets, // use unit structs without braces
|
||||
)]
|
||||
// Advisory lints: useful, but not fatal
|
||||
#![warn(
|
||||
clippy::assertions_on_result_states, // avoid asserts on Result state
|
||||
clippy::match_like_matches_macro, // prefer matches! macro over verbose match
|
||||
clippy::needless_continue, // remove redundant continue statements
|
||||
clippy::unused_trait_names, // drop unused trait imports
|
||||
clippy::verbose_file_reads, // prefer concise file read helpers
|
||||
clippy::as_conversions, // discourage lossy as casts
|
||||
clippy::pattern_type_mismatch, // catch mismatched types in patterns
|
||||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(clippy::doc_lazy_continuation)]
|
||||
// Use README.md as crate documentation.
|
||||
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
|
||||
// We'll default to building for no_std - use core, alloc instead of std.
|
||||
@@ -86,10 +181,10 @@ use std::collections::{hash_map::Entry as MapEntry, HashMap as Map, HashSet as S
|
||||
use alloc::collections::{btree_map::Entry as MapEntry, BTreeMap as Map, BTreeSet as Set};
|
||||
|
||||
use alloc::{
|
||||
borrow::ToOwned,
|
||||
borrow::ToOwned as _,
|
||||
boxed::Box,
|
||||
format,
|
||||
string::{String, ToString},
|
||||
string::{String, ToString as _},
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
@@ -414,6 +509,7 @@ impl fmt::Debug for dyn Extension {
|
||||
pub mod coverage {
|
||||
use crate::*;
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
/// Coverage information about a rego policy file.
|
||||
pub struct File {
|
||||
@@ -430,6 +526,7 @@ pub mod coverage {
|
||||
pub not_covered: alloc::collections::BTreeSet<u32>,
|
||||
}
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
/// Policy coverage report.
|
||||
pub struct Report {
|
||||
@@ -444,6 +541,7 @@ pub mod coverage {
|
||||
/// Lines that are not covered are red.
|
||||
///
|
||||
/// <img src="https://github.com/microsoft/regorus/blob/main/docs/coverage.png?raw=true">
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
pub fn to_string_pretty(&self) -> anyhow::Result<String> {
|
||||
let mut s = String::default();
|
||||
s.push_str("COVERAGE REPORT:\n");
|
||||
@@ -454,8 +552,8 @@ pub mod coverage {
|
||||
}
|
||||
|
||||
s.push_str(&format!("{}:\n", file.path));
|
||||
for (line, code) in file.code.split('\n').enumerate() {
|
||||
let line = line as u32 + 1;
|
||||
for (line_idx, code) in file.code.split('\n').enumerate() {
|
||||
let line = u32::try_from(line_idx + 1).unwrap_or(u32::MAX);
|
||||
if file.not_covered.contains(&line) {
|
||||
s.push_str(&format!("\x1b[31m {line:4} {code}\x1b[0m\n"));
|
||||
} else if file.covered.contains(&line) {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::std_instead_of_core,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::if_then_some_else_none,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
//! Lookup table for associating data structures with AST nodes.
|
||||
//!
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::float_cmp,
|
||||
clippy::unwrap_used,
|
||||
clippy::unreachable,
|
||||
clippy::option_if_let_else,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::unused_self,
|
||||
clippy::print_stderr,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
#![allow(missing_debug_implementations)] // parser types are internal
|
||||
|
||||
use crate::ast::*;
|
||||
use crate::lexer::*;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(missing_debug_implementations)] // policy info structs used for serialization only
|
||||
|
||||
#[cfg(feature = "azure_policy")]
|
||||
use crate::engine::PolicyParameters;
|
||||
use crate::*;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#![allow(
|
||||
clippy::if_then_some_else_none,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(missing_debug_implementations, clippy::pattern_type_mismatch)] // registry internals are not debug logged
|
||||
#![allow(dead_code)]
|
||||
use crate::*;
|
||||
use core::fmt;
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::unwrap_used,
|
||||
clippy::expect_used,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::assertions_on_result_states
|
||||
)] // registry tests unwrap/panic to assert outcomes
|
||||
|
||||
use super::super::registry::*;
|
||||
use crate::{schema::Schema, *};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::unwrap_used,
|
||||
clippy::unreachable,
|
||||
clippy::indexing_slicing,
|
||||
clippy::assertions_on_result_states,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // registry effect tests unwrap/panic for invariant checks
|
||||
|
||||
use super::super::registry::*;
|
||||
use crate::{
|
||||
registry::{instances::EFFECT_SCHEMA_REGISTRY, schemas::effect},
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::unwrap_used,
|
||||
clippy::unreachable,
|
||||
clippy::indexing_slicing,
|
||||
clippy::assertions_on_result_states,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // registry resource tests unwrap/panic for fixture setup
|
||||
|
||||
use super::super::registry::*;
|
||||
use crate::{
|
||||
registry::{instances::RESOURCE_SCHEMA_REGISTRY, schemas::resource},
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::unwrap_used,
|
||||
clippy::indexing_slicing,
|
||||
clippy::unreachable,
|
||||
clippy::assertions_on_result_states,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // registry target tests unwrap/panic for expectations
|
||||
|
||||
use super::super::registry::*;
|
||||
use crate::{
|
||||
registry::{instances::TARGET_REGISTRY, targets},
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#![allow(
|
||||
clippy::option_if_let_else,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_const_for_fn)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#![allow(
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names
|
||||
)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::unwrap_used,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::indexing_slicing,
|
||||
clippy::option_if_let_else,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::unused_trait_names)]
|
||||
|
||||
use super::Program;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::as_conversions,
|
||||
clippy::unused_trait_names
|
||||
)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(clippy::as_conversions, clippy::unused_trait_names)]
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::redundant_pub_crate)]
|
||||
|
||||
pub(crate) mod binary;
|
||||
mod json;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::redundant_pub_crate,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use alloc::collections::{BTreeMap, BTreeSet};
|
||||
use alloc::format;
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#![allow(clippy::missing_const_for_fn)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::as_conversions
|
||||
)]
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::unwrap_used,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::option_if_let_else,
|
||||
clippy::unused_trait_names,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // tests unwrap conversions and slice math for brevity
|
||||
|
||||
use crate::rvm::instructions::{Instruction, LoopMode};
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::as_conversions
|
||||
)]
|
||||
|
||||
//! Test utility functions for RVM serialization
|
||||
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::panic,
|
||||
clippy::panic_in_result_fn,
|
||||
clippy::unwrap_used,
|
||||
clippy::manual_assert,
|
||||
clippy::indexing_slicing,
|
||||
clippy::option_if_let_else,
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::use_debug,
|
||||
clippy::unused_trait_names,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // VM tests assert/unwrap and use manual panics to validate scenarios
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::rvm::tests::instruction_parser::{parse_instruction, parse_loop_mode};
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
#![allow(
|
||||
clippy::unused_self,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::unseparated_literal_suffix,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::option_if_let_else,
|
||||
clippy::useless_let_if_seq,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::rvm::instructions::{ComprehensionBeginParams, ComprehensionMode};
|
||||
use crate::value::Value;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::rvm::instructions::{ComprehensionMode, LoopMode};
|
||||
use crate::value::Value;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::used_underscore_binding,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::rvm::instructions::{Instruction, LiteralOrRegister};
|
||||
use crate::rvm::program::Program;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::expect_used,
|
||||
clippy::option_if_let_else,
|
||||
clippy::as_conversions,
|
||||
clippy::needless_continue,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
use crate::rvm::instructions::Instruction;
|
||||
use crate::rvm::program::Program;
|
||||
use crate::value::Value;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_const_for_fn)]
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(clippy::indexing_slicing, clippy::as_conversions)]
|
||||
use crate::builtins;
|
||||
use crate::value::Value;
|
||||
use alloc::string::String;
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
clippy::indexing_slicing,
|
||||
clippy::expect_used,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::unwrap_used,
|
||||
clippy::shadow_unrelated,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::unused_self,
|
||||
clippy::as_conversions,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // VM loop handling indexes directly for performance and clarity
|
||||
|
||||
use crate::rvm::instructions::LoopMode;
|
||||
use crate::value::Value;
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#![allow(
|
||||
missing_debug_implementations,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::pattern_type_mismatch
|
||||
)] // VM structs are not debug printed
|
||||
|
||||
use crate::rvm::program::Program;
|
||||
use crate::value::Value;
|
||||
use crate::CompiledPolicy;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod arithmetic;
|
||||
mod comprehension;
|
||||
mod context;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user