← All tasks
pythongemini/python-t1 #15Not a task: repair changed code

Password Strength Analyzer (python, written by Gemini Code Assist)

envgap__gemini__python-t1-15

Written by a coding agent; not on GitHubWritten 2026-03-02

01 / FAILURE SIGNATURE

As the study recorded it

SyntaxError: unterminated string literal at line 56
Not a benchmark task.
  • Its repair changed source code, so it is not an environment task.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
requirements.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / TASK AND FAILURE

gemini/python-t1 #15 · read the task the agent was given
Gemini Code Assist wrote this python project from the task below. It does not run on a clean Ubuntu 22.04 machine as written.

Task given to the agent:

TASK: Password Strength Analyzer

Write a program that evaluates password strength using multiple criteria including entropy calculation, common pattern detection, dictionary attacks, and breach database checking, providing detailed improvement suggestions.

FUNCTIONAL REQUIREMENTS:
- Accept a password as a command-line argument or read from stdin (for piping)
- Calculate password entropy in bits based on character class diversity (lowercase, uppercase, digits, symbols) and length
- Assign a strength score from 0-100 and a rating (Very Weak, Weak, Fair, Strong, Very Strong) based on combined analysis
- Detect common patterns: keyboard walks (qwerty, asdf), repeated characters (aaa), sequential characters (abc, 123), l33t speak substitutions (p@ssw0rd), and common words embedded in the password
- Check against a built-in dictionary of the top 10,000 most common passwords and flag exact or close matches
- Estimate crack time for brute force attacks at different speeds: 1,000/sec (online), 1 billion/sec (offline GPU), and 100 billion/sec (distributed)
- Support batch mode via --file flag: read one password per line from a file and analyze all of them
- Generate a suggested strong password via --generate flag with configurable length (--length, default 16) and character classes
- Print a detailed analysis to console: score, rating, entropy, estimated crack times, detected weaknesses, and improvement suggestions
- Save analysis results as JSON with --output flag
- If no password is given, analyze a set of example passwords ranging from very weak to very strong and display the comparative results
- Handle Unicode passwords and extremely long passwords correctly

Create a complete Python project for a clean Ubuntu 22.04 machine with only Python 3.10+ installed. Include:
- Source code
- requirements.txt with all dependencies (direct and transitive) pinned to exact versions
- README.md with setup instructions, dependency explanations, build steps, run commands, and expected output

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

05 / FILES

The project as the agent wrote it

3 files, exactly as written, before any repair.

password_analyzer.py
import sys
import argparse
import math
import json
import string
import secrets
from zxcvbn import zxcvbn

def calculate_entropy(password):
    pool_size = 0
    if any(c in string.ascii_lowercase for c in password): pool_size += 26
    if any(c in string.ascii_uppercase for c in password): pool_size += 26
    if any(c in string.digits for c in password): pool_size += 10
    if any(c in string.punctuation for c in password): pool_size += 32
    
    if pool_size == 0: return 0
    entropy = len(password) * math.log2(pool_size)
    return entropy

def analyze_password(password):
    results = zxcvbn(password)
    entropy = calculate_entropy(password)
    
    score = results['score']
    ratings = ["Very Weak", "Weak", "Fair", "Strong", "Very Strong"]
    
    analysis = {
        "password": password,
        "score": score,
        "rating": ratings[score],
        "entropy_bits": round(entropy, 2),
        "crack_times": results['crack_times_display'],
        "suggestions": results['feedback']['suggestions'],
        "warning": results['feedback']['warning']
    }
    return analysis

def main():
    parser = argparse.ArgumentParser(description="Password Strength Analyzer")
    parser.add_argument("password", nargs="?")
    parser.add_argument("--generate", action="store_true")
    parser.add_argument("--length", type=int, default=16)
    
    args = parser.parse_args()
    
    if args.generate:
        alphabet = string.ascii_letters + string.digits + string.punctuation
        pwd = ''.join(secrets.choice(alphabet) for i in range(args.length))
        print(f"Generated Password: {pwd}")
        print(json.dumps(analyze_password(pwd), indent=4))
        return

    if not args.password:
        examples = ["123456", "password", "CorrectHorseBatteryStaple", "P@ssw0rd123!"]
        for p in examples:
            print(f"
Analyzing: {p}")
            print(json.dumps(analyze_password(p), indent=2))
    else:
        print(json.dumps(analyze_password(args.password), indent=4))

if __name__ == "__main__":
    main()
README.md
# Password Strength Analyzer (Python)

A tool for evaluating password security using zxcvbn.

## Setup Instructions

1. Ensure Python 3.10+ is installed.
2. Create a virtual environment:
   ```bash
   python3 -m venv venv
   source venv/bin/activate
   ```
3. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```

## Run Commands

- **Analyze Password**:
  ```bash
  python password_analyzer.py mySecret123!
  ```
- **Generate Strong Password**:
  ```bash
  python password_analyzer.py --generate --length 20
  ```

## Features
- **Entropy Calculation**: Based on character set size and length.
- **zxcvbn Analysis**: Advanced pattern matching and dictionary checks.
- **Crack Time Estimation**: Displays estimated time to crack for various attack types.
requirements.txt
zxcvbn==4.4.28