CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-safety

Scan dependencies for known vulnerabilities and licenses.

Overall
score

61%

Overview
Eval results
Files

task.mdevals/scenario-10/

Security Policy Manager

A Python module that manages security policies for dependency scanning, including policy file generation, validation, and loading with proper configuration handling.

Overview

Build a module that provides policy management functionality for a security scanning tool. The module should generate policy configuration files, validate policy structures, and load policies from files with proper error handling.

Capabilities

Policy File Generation

  • It generates a valid policy file in YAML format with default security settings @test
  • It creates policy files with CVSS severity threshold configuration @test
  • It includes vulnerability ignore rules with expiration dates in generated policies @test

Policy Validation

  • It validates that a policy file has the correct YAML structure @test
  • It checks that CVSS severity thresholds are valid numeric values @test
  • It verifies that vulnerability ignore rules contain required fields (id, reason, expires) @test
  • It validates that expiration dates are in the correct format (YYYY-MM-DD) @test

Policy Loading

  • It loads a policy file and returns a structured configuration object @test
  • It handles missing policy files gracefully with appropriate error messages @test
  • It parses CVSS threshold settings from the loaded policy @test
  • It extracts vulnerability ignore rules from the policy configuration @test

Implementation

@generates

API

def generate_policy_file(output_path: str, include_defaults: bool = True) -> None:
    """
    Generate a policy configuration file with security settings.

    Args:
        output_path: Path where the policy file should be written
        include_defaults: Whether to include default security settings
    """
    pass

def validate_policy_file(policy_path: str) -> dict:
    """
    Validate the structure and contents of a policy file.

    Args:
        policy_path: Path to the policy file to validate

    Returns:
        dict with 'valid' (bool) and 'errors' (list) keys
    """
    pass

def load_policy_file(policy_path: str) -> dict:
    """
    Load and parse a policy configuration file.

    Args:
        policy_path: Path to the policy file

    Returns:
        dict containing the parsed policy configuration

    Raises:
        FileNotFoundError: If the policy file doesn't exist
        ValueError: If the policy file is invalid
    """
    pass

Dependencies { .dependencies }

safety { .dependency }

Provides vulnerability scanning and policy management capabilities for Python dependencies.

Install with Tessl CLI

npx tessl i tessl/pypi-safety

tile.json