| Crates.io | nacm-validator |
| lib.rs | nacm-validator |
| version | 0.2.0 |
| created_at | 2025-08-29 18:12:35.023259+00 |
| updated_at | 2025-09-02 18:48:37.483375+00 |
| description | NACM (Network Access Control Model) validator with Tail-f ACM extensions and multiple configuration files support |
| homepage | https://github.com/etnt/nacm-validator |
| repository | https://github.com/etnt/nacm-validator |
| max_upload_size | |
| id | 1816245 |
| size | 164,198 |
A Rust implementation of NACM (Network Access Control Model) validator as defined in RFC 8341, with support for Tail-f ACM extensions for command-based access control. This library and CLI tool demonstrate parsing real NACM XML configurations and validating access requests against defined rules.
The NACM Validator provides both a library (nacm-validator) for developers and a command-line tool (nacm-validator) for end users.
The CLI tool is now published to crates.io! Install it with:
cargo install nacm-validator-cli
This will install the nacm-validator binary to ~/.cargo/bin/ (make sure it's in your PATH).
Alternatively, you can install from source:
# Clone the repository
git clone https://github.com/etnt/nacm-validator.git
cd nacm-validator
# Install the CLI tool globally from source
cargo install --path nacm-validator-bin
After installation, you can run the tool from anywhere:
nacm-validator --help
To use the validator library in your own Rust project, add it to your Cargo.toml:
[dependencies]
nacm-validator = "0.2"
You can also use the git dependency for the latest development version:
[dependencies]
# For the latest published version (recommended):
nacm-validator = "0.2"
# Or for the latest development version:
# nacm-validator = { git = "https://github.com/etnt/nacm-validator.git", package = "nacm-validator" }
Then import the library in your Rust code:
use nacm_validator::{NacmConfig, AccessRequest, Operation, RequestContext};
If you want to develop or contribute to the project:
# Clone the repository
git clone https://github.com/etnt/nacm-validator.git
cd nacm-validator
# Build the workspace (both library and CLI)
cargo build
# Run tests
cargo test
# Build documentation
cargo doc --open
# Run examples
cargo run --example tailf_acm_demo
The NACM Validator now supports loading and merging multiple configuration files from a directory, enabling modular configuration management:
# Load multiple configuration files from a directory
./target/release/nacm-validator \
--config-dir nacm-validator-bin/examples/test-configs \
--user alice \
--operation read \
--verbose
# Output: Loads and merges all XML files in nacm-validator-bin/examples/test-configs/ directory
# Run the comprehensive multiple files demo
./nacm-validator-bin/examples/multiple_files_demo.sh
# Traditional single file still works (backward compatible)
./target/release/nacm-validator \
--config single-config.xml \
--user alice \
--operation read
Key Benefits of Multiple Files:
The nacm-validator-bin/examples/test-configs/ directory demonstrates a typical modular setup:
nacm-validator-bin/examples/test-configs/
βββ 01-base.xml # Base NACM settings and admin group
βββ 02-operators.xml # Operator groups and data access rules
βββ 03-commands.xml # Command-based access rules (Tail-f ACM)
βββ invalid.xml # Invalid XML to demonstrate error handling
βββ test-file.xml # Additional config to show merging capabilities
File Processing Rules:
# Load all configurations and show merge results
./target/release/nacm-validator \
--config-dir nacm-validator-bin/examples/test-configs \
--user alice \
--operation read \
--verbose
# Output shows:
# Loading config directory: "nacm-validator-bin/examples/test-configs"
# Found 5 XML configuration files:
# 1. "01-base.xml"
# 2. "02-operators.xml"
# 3. "03-commands.xml"
# 4. "invalid.xml"
# 5. "test-file.xml"
# β Successfully loaded: "01-base.xml"
# β Successfully loaded: "02-operators.xml"
# β Successfully loaded: "03-commands.xml"
# β Failed to load "invalid.xml": Syntax error...
# β Successfully loaded: "test-file.xml"
# Warning: 1 out of 5 files failed to load, continuing with 4 valid configurations
# Merging 4 configurations...
# β Configuration merge completed
# - 4 groups loaded
# - 3 rule lists loaded
# - 3 total rules loaded
# Build the CLI tool (if developing from source)
cargo build --release
# Test data access (standard NACM)
./target/release/nacm-validator \
--config nacm-validator-lib/examples/data/aaa_ncm_init_secure.xml \
--user admin \
--operation exec \
--rpc edit-config \
--context netconf
# Output: PERMIT
# Test with denied user
./target/release/nacm-validator \
--config nacm-validator-lib/examples/data/aaa_ncm_init_secure.xml \
--user unknown \
--operation exec \
--rpc edit-config \
--context netconf
# Output: DENY (exit code 1)
# Test command-based access control
./target/release/nacm-validator \
--config nacm-validator-lib/examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context cli \
--command "show status"
# Output: PERMIT [LOGGED]
# Test context-aware access
./target/release/nacm-validator \
--config nacm-validator-lib/examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context netconf \
--module "ietf-interfaces" \
--path "/interfaces"
# Output: PERMIT [LOGGED]
# JSON batch processing with enhanced fields
echo '{"user":"alice","operation":"read","context":"cli","command":"show status"}' | \
./target/release/nacm-validator \
--config nacm-validator-lib/examples/data/tailf_acm_example.xml \
--json-input
# Output: {"decision":"permit","user":"alice","context":"cli","command":"show status","should_log":true,...}
use nacm_validator::{AccessRequest, NacmConfig, Operation, RequestContext};
let config = NacmConfig::from_xml(&xml_content)?;
let context = RequestContext::CLI;
let request = AccessRequest {
user: "alice",
operation: Operation::Read,
context: Some(&context),
command: Some("show status"),
module_name: None,
rpc_name: None,
path: None,
};
let result = config.validate(&request);
println!("Access {}: {}",
if result.effect == nacm_validator::RuleEffect::Permit { "GRANTED" } else { "DENIED" },
if result.should_log { "[LOGGED]" } else { "" });
# NEW: Multiple files configuration demo
./nacm-validator-bin/examples/multiple_files_demo.sh
# Comprehensive feature demonstration
cargo run --example tailf_acm_comprehensive_demo
# Interactive shell examples
cd nacm-validator-bin/examples && bash bash_examples.sh
# JSON batch processing
cd nacm-validator-bin/examples && bash json_batch_example.sh
--config-dir--config and --config-dir options are mutually exclusive for safety--config single file usage unchanged<cmdrule>)log-if-permit/log-if-deny<gid> mapping# Clone the repository
git clone <repository-url>
cd nacm-validator
# Build the project (library and CLI tool)
cargo build
# Build in release mode (optimized)
cargo build --release
# Build just the CLI tool
cargo build --bin nacm-validator
# Build just the library
cargo build --lib
The project includes comprehensive tests covering XML parsing and access validation:
# Run all tests
cargo test
# Run tests with detailed output
cargo test -- --nocapture
# Run a specific test
cargo test test_real_nacm_xml
# Run tests and show successful test output
cargo test -- --show-output
The tests include:
The main example demonstrates parsing a real NACM XML file and validating various access scenarios:
cargo run --example validate_access
This example shows:
Run the comprehensive Tail-f ACM demo to see all the advanced features in action:
cargo run --example tailf_acm_demo
This demo showcases:
Example Output:
π§ Tail-f ACM Configuration loaded:
- NACM enabled: true
- Default policies:
* Data: read=Deny, write=Deny, exec=Deny
* Commands: cmd_read=Deny, cmd_exec=Deny
- Logging: default_permit=true, default_deny=true
- Groups: ["operators", "admin"]
* operators (GID: 1000): ["alice", "bob"]
* admin (GID: 0): ["admin"]
- Rule lists: 2
π Command access validation results:
β
Alice (operator) - CLI show status: PERMIT π[LOG]
β Bob (operator) - CLI reboot: DENY π[LOG]
β
Admin - WebUI config backup: PERMIT
...
Example Output:
NACM Configuration loaded:
- NACM enabled: true
- Default policies: read=Deny, write=Deny, exec=Deny
- Groups: ["oper", "admin"]
- Rule lists: 3
Access validation results:
- Admin executing edit-config: β
PERMIT
- Oper executing edit-config: β DENY
- Oper modifying NACM config: β DENY
- Guest reading example/misc/data: β
PERMIT
- Guest creating example/misc: β
PERMIT
- Unknown user reading data: β
PERMIT
nacm-validator/
βββ nacm-validator-lib/
β βββ src/lib.rs # Main library with Tail-f ACM extensions
β βββ examples/
β βββ validate_access.rs # Basic access validation example
β βββ tailf_acm_demo.rs # Tail-f ACM features demonstration
β βββ tailf_acm_comprehensive_demo.rs # Comprehensive feature showcase
β βββ README.md # Examples documentation
β βββ data/
β βββ aaa_ncm_init.xml # Basic NACM configuration (insecure)
β βββ aaa_ncm_init_secure.xml # Secure NACM configuration
β βββ tailf_acm_example.xml # Comprehensive Tail-f ACM example
βββ nacm-validator-bin/
β βββ src/main.rs # Enhanced CLI tool with multiple files support
β βββ examples/
β βββ bash_examples.sh # Bash integration with Tail-f ACM
β βββ json_batch_example.sh # JSON batch processing example
β βββ multiple_files_demo.sh # NEW: Multiple files functionality demo
β βββ test-configs/ # NEW: Example multiple config files
β βββ 01-base.xml # Base configuration
β βββ 02-operators.xml # Operator groups and rules
β βββ 03-commands.xml # Command-based rules
β βββ invalid.xml # Invalid XML (for error demo)
β βββ test-file.xml # Additional config (for merging demo)
βββ doc/
β βββ rfc-tailf-acm-proposal.md # Tail-f ACM RFC proposal document
βββ Cargo.toml # Workspace configuration
βββ README.md # This file
The original aaa_ncm_init.xml contains a security vulnerability - it has a catch-all rule that permits access for any user (including unknown users). This is dangerous:
<rule>
<name>any-access</name>
<action>permit</action>
</rule>
# β INSECURE: Unknown user 'bill' gets access with original config
./target/release/nacm-validator \
--config examples/data/aaa_ncm_init.xml \
--user bill \
--operation exec \
--rpc edit-config
# Output: PERMIT (this is wrong!)
# β
SECURE: Unknown user 'bill' denied with secure config
./target/release/nacm-validator \
--config examples/data/aaa_ncm_init_secure.xml \
--user bill \
--operation exec \
--rpc edit-config
# Output: DENY (this is correct!)
Always use aaa_ncm_init_secure.xml for production-like testing.
Add this to your Cargo.toml:
[dependencies]
nacm-validator = "0.2.0"
use nacm_validator::{AccessRequest, NacmConfig, Operation, RequestContext, ValidationResult, RuleEffect};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load NACM configuration from XML
let xml_content = std::fs::read_to_string("examples/data/tailf_acm_example.xml")?;
let config = NacmConfig::from_xml(&xml_content)?;
// Create a data access request
let netconf_context = RequestContext::NETCONF;
let data_request = AccessRequest {
user: "alice",
module_name: Some("ietf-interfaces"),
rpc_name: None,
operation: Operation::Read,
path: Some("/interfaces"),
context: Some(&netconf_context),
command: None,
};
// Validate the data request
let result = config.validate(&data_request);
println!("Data access {}: {}",
if result.effect == RuleEffect::Permit { "PERMITTED" } else { "DENIED" },
if result.should_log { "[LOGGED]" } else { "" });
// Create a command access request (Tail-f extension)
let cli_context = RequestContext::CLI;
let command_request = AccessRequest {
user: "alice",
module_name: None,
rpc_name: None,
operation: Operation::Read,
path: None,
context: Some(&cli_context),
command: Some("show interfaces"),
};
// Validate the command request
let cmd_result = config.validate(&command_request);
println!("Command access {}: {}",
if cmd_result.effect == RuleEffect::Permit { "PERMITTED" } else { "DENIED" },
if cmd_result.should_log { "[LOGGED]" } else { "" });
Ok(())
}
use nacm_validator::{AccessRequest, NacmConfig, Operation, RequestContext, ValidationResult};
fn validate_multi_context_access(config: &NacmConfig, user: &str, command: &str) {
let contexts = [
("CLI", RequestContext::CLI),
("WebUI", RequestContext::WebUI),
("NETCONF", RequestContext::NETCONF),
];
println!("Validating command '{}' for user '{}' across contexts:", command, user);
for (name, context) in contexts {
let request = AccessRequest {
user,
module_name: None,
rpc_name: None,
operation: Operation::Read,
path: None,
context: Some(&context),
command: Some(command),
};
let result = config.validate(&request);
let status = if result.effect == nacm_validator::RuleEffect::Permit { "β
PERMIT" } else { "β DENY" };
let log_indicator = if result.should_log { " [LOGGED]" } else { "" };
println!(" {}: {}{}", name, status, log_indicator);
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let xml_content = std::fs::read_to_string("examples/data/tailf_acm_example.xml")?;
let config = NacmConfig::from_xml(&xml_content)?;
// Test command access across different contexts
validate_multi_context_access(&config, "alice", "show status");
validate_multi_context_access(&config, "bob", "reboot");
validate_multi_context_access(&config, "charlie", "help");
Ok(())
}
The validate() method returns a ValidationResult struct containing:
effect: RuleEffect::Permit or RuleEffect::Denyshould_log: Whether this decision should be logged based on the rule's logging configuration (Tail-f ACM extension)Command rules take priority over data access rules when a command is specified:
let request = AccessRequest {
user: "alice",
module_name: Some("ietf-interfaces"), // This would normally match data rules
rpc_name: None,
operation: Operation::Read,
path: Some("/interfaces"),
context: Some(&RequestContext::CLI),
command: Some("show status"), // Command rules take priority
};
// The validator will check command rules first, then fall back to data rules
let result = config.validate(&request);
Rules can specify granular logging behavior:
// Check if access decision should be logged
let result = config.validate(&request);
if result.should_log {
log::info!("Access {} for user {} on command {:?}",
if result.effect == RuleEffect::Permit { "granted" } else { "denied" },
request.user,
request.command);
}
Groups can include GID mapping for OS-level integration:
// Configuration parsing includes GID information
let config = NacmConfig::from_xml(&xml_content)?;
for (group_name, group) in &config.groups {
if let Some(gid) = group.gid {
println!("Group {} maps to OS GID {}", group_name, gid);
}
}
# Build the CLI tool
cargo build --bin nacm-validator
# Validate a simple request (using secure config)
cargo run --bin nacm-validator -- \
--config examples/data/aaa_ncm_init_secure.xml \
--user admin \
--operation exec \
--rpc edit-config
# Output: PERMIT (exit code 0)
# Test denied access
cargo run --bin nacm-validator -- \
--config examples/data/aaa_ncm_init_secure.xml \
--user oper \
--operation exec \
--rpc edit-config
# Output: DENY (exit code 1)
# Test unknown user (should be denied)
cargo run --bin nacm-validator -- \
--config examples/data/aaa_ncm_init_secure.xml \
--user unknown \
--operation exec \
--rpc edit-config
# Output: DENY (exit code 1)
Generate and view the complete API documentation:
cargo doc --open
This opens the documentation in your browser, showing all available types, traits, and functions.
NacmConfig: Main configuration containing groups, rule lists, and policiesNacmRule: Individual data access control ruleNacmRuleList: Named collection of rules applying to specific groupsNacmGroup: User group definition with member listAccessRequest: Represents an access attempt with context informationRuleEffect: Permit or Deny decisionOperation: CRUD + Exec operationsNacmCommandRule: Command-based access control ruleRequestContext: Management interface context (CLI, NETCONF, WebUI)ValidationResult: Enhanced result with access decision and logging flagAccessRequest {
user: "alice", // Username making the request
module_name: Some("ietf-interfaces"), // YANG module (for data access)
rpc_name: Some("edit-config"), // RPC name (for RPC operations)
operation: Operation::Read, // Type of operation
path: Some("/interfaces/*"), // XPath or data path
context: Some(&RequestContext::CLI), // Request context (Tail-f ACM)
command: Some("show status"), // Command (Tail-f ACM)
}
ValidationResult {
effect: RuleEffect::Permit, // Access decision
should_log: true, // Whether to log this decision (Tail-f ACM)
}
NacmRule {
name: "allow-admin-read".to_string(),
module_name: Some("ietf-interfaces".to_string()),
rpc_name: None,
path: Some("/interfaces/*".to_string()),
access_operations: [Operation::Read].into(),
effect: RuleEffect::Permit,
order: 10,
context: None, // Apply to all contexts
log_if_permit: false, // Don't log permits
log_if_deny: false, // Don't log denies
}
NacmCommandRule {
name: "cli-show-commands".to_string(),
context: Some("cli".to_string()), // Apply only to CLI context
command: Some("show *".to_string()), // Wildcard command matching
access_operations: [Operation::Read].into(),
effect: RuleEffect::Permit,
order: 10,
log_if_permit: true, // Log successful commands
log_if_deny: true, // Log blocked commands
comment: Some("Allow operators to view system state".to_string()),
}
NacmGroup {
name: "operators".to_string(),
users: vec!["alice".to_string(), "bob".to_string()],
gid: Some(1000), // OS group ID mapping (Tail-f ACM)
}
pub enum RequestContext {
NETCONF, // NETCONF protocol access
CLI, // Command-line interface access
WebUI, // Web-based user interface access
Other(String), // Custom interface
}
// Context matching supports wildcards
context.matches("*") // Matches any context
context.matches("cli") // Matches CLI exactly
The project includes a powerful CLI tool with full support for Tail-f ACM extensions, enabling both traditional data access validation and command-based access control from bash scripts and automation.
# Build the CLI tool
cargo build --bin nacm-validator
# Build optimized version
cargo build --bin nacm-validator --release
# The binary will be available at:
# ./target/debug/nacm-validator (debug build)
# ./target/release/nacm-validator (release build)
# Standard NACM data access validation
./target/release/nacm-validator \
--config examples/data/aaa_ncm_init_secure.xml \
--user admin \
--operation exec \
--rpc edit-config
# Tail-f ACM command access validation
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context cli \
--command "show status"
# Context-aware data access
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context netconf \
--module "ietf-interfaces" \
--path "/interfaces"
# Output: PERMIT [LOGGED] or DENY [LOGGED] - shows logging indicator
Options:
-c, --config <CONFIG> Path to the NACM XML configuration file
--config-dir <DIR> Path to directory containing multiple XML files (NEW!)
-u, --user <USER> Username making the request
-m, --module <MODULE> Module name (optional)
-r, --rpc <RPC> RPC name (optional)
-o, --operation <OPERATION> Operation type [read, create, update, delete, exec]
-p, --path <PATH> Path (optional)
-x, --context <CONTEXT> Request context [netconf, cli, webui] (Tail-f ACM)
-C, --command <COMMAND> Command being executed (Tail-f ACM)
--format <FORMAT> Output format [text, json, exit-code]
-v, --verbose Verbose output
--json-input JSON input mode - read requests from stdin
Multiple Files Usage:
# Load all XML files from directory (NEW!)
./target/release/nacm-validator \
--config-dir /etc/nacm/configs.d \
--user alice \
--operation read \
--verbose
# Files are processed alphabetically: 01-base.xml, 02-groups.xml, etc.
# Later files can override settings from earlier files (YANG merge semantics)
# Cannot combine both options (mutual exclusion)
./target/release/nacm-validator \
--config single.xml \
--config-dir multi/ \
--user alice --operation read
# Error: cannot use both --config and --config-dir
# Different contexts may have different access policies
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context cli \
--command "show status"
# Output: PERMIT [LOGGED]
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context netconf \
--module "ietf-interfaces"
# Output: PERMIT [LOGGED]
# JSON input with Tail-f ACM fields
echo '{"user":"alice","operation":"read","context":"cli","command":"show status"}' | \
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--json-input
# Output includes enhanced fields:
{
"decision": "permit",
"user": "alice",
"operation": "read",
"context": "cli",
"command": "show status",
"should_log": true,
"config_loaded": true
}
#!/bin/bash
CONFIG="examples/data/tailf_acm_example.xml"
# Command-based validation
if ./target/release/nacm-validator \
--config "$CONFIG" \
--user alice \
--operation read \
--context cli \
--command "show status" \
--format exit-code; then
echo "CLI command access granted"
else
echo "CLI command access denied"
fi
# Context-aware function
validate_command() {
local user="$1"
local context="$2"
local command="$3"
if ./target/release/nacm-validator \
--config "$CONFIG" \
--user "$user" \
--operation read \
--context "$context" \
--command "$command" \
--format exit-code; then
echo "β
$user can execute '$command' via $context"
else
echo "β $user cannot execute '$command' via $context"
fi
}
validate_command "alice" "cli" "show status"
validate_command "alice" "webui" "help"
validate_command "charlie" "cli" "show status"
# Process enhanced JSON output
JSON_OUTPUT=$(./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--user alice \
--operation read \
--context cli \
--command "show interfaces" \
--format json)
# Extract enhanced fields
DECISION=$(echo "$JSON_OUTPUT" | jq -r '.decision')
SHOULD_LOG=$(echo "$JSON_OUTPUT" | jq -r '.should_log')
CONTEXT=$(echo "$JSON_OUTPUT" | jq -r '.context')
COMMAND=$(echo "$JSON_OUTPUT" | jq -r '.command')
echo "Decision: $DECISION"
echo "Should log: $SHOULD_LOG"
echo "Context: $CONTEXT"
echo "Command: $COMMAND"
# Create batch requests with enhanced fields
cat > requests.json << 'EOF'
{"user": "alice", "operation": "read", "context": "cli", "command": "show status"}
{"user": "bob", "operation": "exec", "context": "cli", "command": "reboot"}
{"user": "admin", "operation": "read", "context": "netconf", "module": "ietf-interfaces"}
{"user": "charlie", "operation": "read", "context": "webui", "command": "help"}
EOF
# Process batch requests
./target/release/nacm-validator \
--config examples/data/tailf_acm_example.xml \
--json-input < requests.json
# Output shows enhanced information:
{"decision":"permit","user":"alice","operation":"read","context":"cli","command":"show status","should_log":true,"config_loaded":true}
{"decision":"deny","user":"bob","operation":"exec","context":"cli","command":"reboot","should_log":true,"config_loaded":true}
{"decision":"permit","user":"admin","operation":"read","context":"netconf","module":"ietf-interfaces","should_log":false,"config_loaded":true}
{"decision":"deny","user":"charlie","operation":"read","context":"webui","command":"help","should_log":true,"config_loaded":true}
The project includes comprehensive working examples demonstrating all features:
# Standard NACM access validation with context awareness
cargo run --example validate_access
# Focused Tail-f ACM extensions demonstration
cargo run --example tailf_acm_demo
# Comprehensive Tail-f ACM feature showcase
cargo run --example tailf_acm_comprehensive_demo
# Interactive bash integration examples with Tail-f ACM
cd nacm-validator-bin/examples && bash bash_examples.sh
# JSON batch processing with enhanced fields
cd nacm-validator-bin/examples && bash json_batch_example.sh
Standard Validation:
NACM Configuration loaded:
- NACM enabled: true
- Standard defaults: read=Deny, write=Deny, exec=Deny
- Command defaults: cmd_read=Permit, cmd_exec=Permit
- Groups: ["oper", "admin"]
- Rule lists: 3
Access validation results:
- Admin executing edit-config (NETCONF): β
PERMIT
- Alice - CLI read interfaces (no command rule): β DENY [LOGGED]
- Admin via WebUI (no command - should use data rules): β
PERMIT
Comprehensive Tail-f ACM Demo:
π§ Comprehensive Tail-f ACM Extensions Demo
==================================================
π Configuration Summary:
- NACM enabled: true
- Standard defaults: read=Deny, write=Deny, exec=Deny
- Command defaults: cmd_read=Deny, cmd_exec=Deny
- Logging: default_permit=true, default_deny=true
π₯ Groups:
operators (GID: 1000): ["alice", "bob"]
admin (GID: 0): ["admin"]
π Rule Lists:
1. operator-rules (groups: ["operators"])
- Standard rules: 1
β’ read-interfaces -> Permit [context: netconf]
- Command rules: 4
β’ cli-show-status -> Permit [context: cli] [command: show status]
β’ any-help -> Permit [context: *] [command: help]
π§ͺ Test Scenarios:
1οΈβ£ Command-Based Access Control:
β
alice (operator) - CLI 'show status': Permit π
β charlie (not in group) - CLI 'show status': Deny π
β
admin - CLI 'reboot' (exec operation): Permit
2οΈβ£ Context-Aware Data Access:
β
alice - NETCONF read interfaces: Permit π
β alice - CLI read interfaces (no command rule): Deny π
β alice - WebUI read interfaces (no command rule): Deny π
These examples demonstrate:
Tests are located in src/lib.rs within the #[cfg(test)] module:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_my_scenario() {
// Your test here
}
}
Add new examples in the examples/ directory:
// examples/my_example.rs
use nacm_validator::*;
fn main() {
// Your example code
}
Run with: cargo run --example my_example
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0). See the LICENSE file for details.
This is a prototype implementation for educational and research purposes.
This is a prototype project. Feel free to experiment and extend the functionality!
# Format code
cargo fmt
# Run clippy for lints
cargo clippy
# Check without building
cargo check
# Clean build artifacts
cargo clean
log-if-permit/log-if-denyThis implementation bridges the gap between academic NACM specifications and real-world network device security requirements, making enterprise-grade access control accessible to Rust developers and system integrators.