pkgrisk 0.1.0

5-second package health and risk analysis for npm, PyPI and crates.io dependencies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::ecosystems::PackageMetadata;
use crate::config::LicenseConfig;

pub fn calculate(metadata: &PackageMetadata, config: &LicenseConfig) -> (u8, String) {
    if let Some(license) = &metadata.license {
        for blocked in &config.blocklist {
            if license.contains(blocked) {
                return (0, format!("Blocked license: {}", license));
            }
        }
        return (100, format!("Allowed: {}", license));
    }
    (50, "Unknown license".to_string())
}