Skip to content
Back to skills

Security Automation

ASecurity

Security automation: scripts, CI gates, scheduled scans

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
securitypythonnodeawstestinggitapici/cdsecurityperformance

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill security-automation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Security Automation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Security Automation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-security-automation/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-security-automation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: security-automation
description: "Security automation: scripts, CI gates, scheduled scans"
version: 1.0.0
---

# Security Automation

## Overview

Security automation is an important means of improving the efficiency of security operations. This skill provides methods, tools, and best practices for security automation.

## Automation Scenarios

### 1. Vulnerability Scanning

**Automated scanning:**
- Scheduled scans
- CI/CD integration
- Result analysis
- Report generation

### 2. Security Testing

**Automated testing:**
- Unit testing
- Integration testing
- Security testing
- Regression testing

### 3. Incident Response

**Automated response:**
- Incident detection
- Automated containment
- Notification and alerting
- Evidence collection

### 4. Compliance Checking

**Automated compliance:**
- Configuration checks
- Policy validation
- Report generation
- Remediation advice

## Tools and Frameworks

### Vulnerability Scanning Automation

**Using the Nessus API:**
```python
import requests

# Create a scan
def create_scan(target, scan_name):
    url = "https://nessus:8834/scans"
    headers = {"X-ApiKeys": "access_key:secret_key"}
    data = {
        "uuid": "template-uuid",
        "settings": {
            "name": scan_name,
            "text_targets": target
        }
    }
    response = requests.post(url, json=data, headers=headers)
    return response.json()

# Launch a scan
def launch_scan(scan_id):
    url = f"https://nessus:8834/scans/{scan_id}/launch"
    headers = {"X-ApiKeys": "access_key:secret_key"}
    response = requests.post(url, headers=headers)
    return response.json()
```

**Using the OpenVAS API:**
```python
from gvm.connections import UnixSocketConnection
from gvm.protocols.gmp import Gmp

# Connect to OpenVAS
connection = UnixSocketConnection()
gmp = Gmp(connection)
gmp.authenticate('username', 'password')

# Create a scan task
target = gmp.create_target(name='target', hosts=['192.168.1.0/24'])
config = gmp.get_configs()[0]
scanner = gmp.get_scanners()[0]

task = gmp.create_task(
    name='scan_task',
    config_id=config['id'],
    target_id=target['id'],
    scanner_id=scanner['id']
)

# Launch the scan
gmp.start_task(task['id'])
```

### CI/CD Integration

**Jenkins Pipeline:**
```groovy
pipeline {
    agent any
    stages {
        stage('Security Scan') {
            steps {
                sh 'npm audit'
                sh 'snyk test'
                sh 'sonar-scanner'
            }
        }
        stage('Vulnerability Scan') {
            steps {
                sh 'nmap --script vuln target'
            }
        }
    }
    post {
        always {
            publishHTML([
                reportDir: 'reports',
                reportFiles: 'report.html',
                reportName: 'Security Report'
            ])
        }
    }
}
```

**GitHub Actions:**
```yaml
name: Security Scan

on: [push, pull_request]

jobs:
  security-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run Snyk
        uses: snyk/actions/node@master
        env:
          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
      - name: Run SonarQube
        uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
```

### Security Testing Automation

**Using OWASP ZAP:**
```python
from zapv2 import ZAPv2

# Launch ZAP
zap = ZAPv2(proxies={'http': 'http://127.0.0.1:8080'})

# Start scanning
zap.urlopen('http://target.com')
zap.spider.scan('http://target.com')
while int(zap.spider.status()) < 100:
    time.sleep(1)

# Active scan
zap.ascan.scan('http://target.com')
while int(zap.ascan.status()) < 100:
    time.sleep(1)

# Get results
alerts = zap.core.alerts()
```

**Using Burp Suite:**
```python
from burp import IBurpExtender, IScannerCheck

class BurpExtender(IBurpExtender, IScannerCheck):
    def registerExtenderCallbacks(self, callbacks):
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()
        callbacks.setExtensionName("Security Automation")
        callbacks.registerScannerCheck(self)
    
    def doPassiveScan(self, baseRequestResponse):
        # Passive scan logic
        return None
    
    def doActiveScan(self, baseRequestResponse, insertionPoint):
        # Active scan logic
        return None
```

### Incident Response Automation

**Using Splunk:**
```python
import splunklib.client as client

# Connect to Splunk
service = client.connect(
    host='splunk.example.com',
    port=8089,
    username='admin',
    password='password'
)

# Search for security events
search_query = 'index=security event_type="malware"'
kwargs = {"earliest_time": "-1h", "latest_time": "now"}
search = service.jobs.create(search_query, **kwargs)

# Process the results
for result in search:
    if result['severity'] == 'high':
        # Automated response
        send_alert(result)
        isolate_system(result['host'])
```

**Using the ELK Stack:**
```python
from elasticsearch import Elasticsearch

# Connect to Elasticsearch
es = Elasticsearch(['localhost:9200'])

# Search for security events
query = {
    "query": {
        "match": {
            "event_type": "intrusion"
        }
    }
}

results = es.search(index="security", body=query)

# Automated response
for hit in results['hits']['hits']:
    if hit['_source']['severity'] == 'critical':
        # Automated containment
        block_ip(hit['_source']['src_ip'])
        send_alert(hit['_source'])
```

## Automation Scripts

### Vulnerability Scanning Script

```python
#!/usr/bin/env python3
import subprocess
import json
import smtplib
from email.mime.text import MIMEText

def run_nmap_scan(target):
    """Run an Nmap scan"""
    result = subprocess.run(
        ['nmap', '--script', 'vuln', '-oJ', '-', target],
        capture_output=True,
        text=True
    )
    return json.loads(result.stdout)

def analyze_results(results):
    """Analyze the scan results"""
    vulnerabilities = []
    for host in results.get('hosts', []):
        for port in host.get('ports', []):
            for script in port.get('scripts', []):
                if script.get('id') == 'vuln':
                    vulnerabilities.append({
                        'host': host['address'],
                        'port': port['portid'],
                        'vuln': script.get('output', '')
                    })
    return vulnerabilities

def send_report(vulnerabilities):
    """Send the report"""
    if vulnerabilities:
        msg = MIMEText(f"Found {len(vulnerabilities)} vulnerabilities")
        msg['Subject'] = 'Vulnerability Scan Report'
        msg['From'] = 'security@example.com'
        msg['To'] = 'admin@example.com'
        
        server = smtplib.SMTP('smtp.example.com')
        server.send_message(msg)
        server.quit()

if __name__ == '__main__':
    target = '192.168.1.0/24'
    results = run_nmap_scan(target)
    vulnerabilities = analyze_results(results)
    send_report(vulnerabilities)
```

### Configuration Check Script

```python
#!/usr/bin/env python3
import boto3
import json

def check_s3_buckets():
    """Check the security configuration of S3 buckets"""
    s3 = boto3.client('s3')
    buckets = s3.list_buckets()
    
    issues = []
    for bucket in buckets['Buckets']:
        # Check for public access
        try:
            acl = s3.get_bucket_acl(Bucket=bucket['Name'])
            for grant in acl.get('Grants', []):
                if grant.get('Grantee', {}).get('URI') == 'http://acs.amazonaws.com/groups/global/AllUsers':
                    issues.append({
                        'bucket': bucket['Name'],
                        'issue': 'Public access enabled'
                    })
        except:
            pass
        
        # Check for encryption
        try:
            encryption = s3.get_bucket_encryption(Bucket=bucket['Name'])
        except:
            issues.append({
                'bucket': bucket['Name'],
                'issue': 'Encryption not enabled'
            })
    
    return issues

if __name__ == '__main__':
    issues = check_s3_buckets()
    print(json.dumps(issues, indent=2))
```

## Best Practices

### 1. Automation Strategy

- Identify scenarios that can be automated
- Develop an automation plan
- Implement incrementally
- Continuously improve

### 2. Tool Selection

- Evaluate tool capabilities
- Consider integration
- Consider cost
- Test and validate

### 3. Process Design

- Define clear process steps
- Define trigger conditions
- Set up exception handling
- Log operations

### 4. Monitoring and Maintenance

- Monitor automation tasks
- Review results regularly
- Update rules and scripts
- Optimize performance

## Notes

- Ensure the accuracy of automation
- Set appropriate permissions
- Protect automation credentials
- Review automation rules regularly

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.