agentsclimarketplace

Secure code review

Skill xAmirHamza77/PenKit51/skills/secure-code-review

PenKit51 — Open-source AI penetration testing platform with 63 deep exploitation skills, multi-agent orchestration, PoC-validated findings, and native assistant skills for Claude, ChatGPT, and Grok. Authorized testing only.

Install
npx -y skills add xAmirHamza77/PenKit51 --skill secure-code-review

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

安全代码审查的专业技能和方法论

SKILL.md

5.1 KB, as published. Nobody here has run it

Secure Code Review

penkit51 AI — professional penetration testing skill pack. Authorized testing only.

Platform Methodology

安全代码审查

概述

安全代码审查是识别代码中安全漏洞的重要方法。本技能提供安全代码审查的方法、工具和最佳实践。

审查范围

1. 输入验证

检查项目:

  • 用户输入验证
  • 参数验证
  • 数据过滤
  • 边界检查

2. 输出编码

检查项目:

  • XSS防护
  • 输出编码
  • 内容安全策略
  • 响应头设置

3. 认证授权

检查项目:

  • 认证机制
  • 会话管理
  • 权限控制
  • 密码处理

4. 加密和密钥

检查项目:

  • 数据加密
  • 密钥管理
  • 哈希算法
  • 随机数生成

审查方法

1. 静态分析

使用SAST工具:

# SonarQube
sonar-scanner

# Checkmarx
# 使用Web界面

# Fortify
sourceanalyzer -b project build.sh
sourceanalyzer -b project -scan

# Semgrep
semgrep --config=auto .

2. 手动审查

审查清单:

  • 输入验证
  • 输出编码
  • SQL注入
  • XSS漏洞
  • 认证授权
  • 加密使用
  • 错误处理
  • 日志记录

3. 代码模式识别

危险函数:

# Python危险函数
eval()
exec()
pickle.loads()
os.system()
subprocess.call()
// Java危险函数
Runtime.exec()
ProcessBuilder()
Class.forName()
// PHP危险函数
eval()
exec()
system()
passthru()

常见漏洞模式

SQL注入

危险代码:

String query = "SELECT * FROM users WHERE id = " + userId;
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(query);

安全代码:

String query = "SELECT * FROM users WHERE id = ?";
PreparedStatement stmt = connection.prepareStatement(query);
stmt.setInt(1, userId);
ResultSet rs = stmt.executeQuery();

XSS漏洞

危险代码:

document.innerHTML = userInput;
element.innerHTML = "<div>" + userInput + "</div>";

安全代码:

element.textContent = userInput;
element.setAttribute("data-value", userInput);
// 或使用编码库
element.innerHTML = escapeHtml(userInput);

命令注入

危险代码:

import os
os.system("ping " + user_input)

安全代码:

import subprocess
subprocess.run(["ping", "-c", "1", validated_input])

路径遍历

危险代码:

String filePath = "/uploads/" + fileName;
File file = new File(filePath);

安全代码:

String basePath = "/uploads/";
String fileName = Paths.get(fileName).getFileName().toString();
String filePath = basePath + fileName;
File file = new File(filePath);
if (!file.getCanonicalPath().startsWith(basePath)) {
    throw new SecurityException("Invalid path");
}

硬编码密钥

危险代码:

String apiKey = "1234567890abcdef";
String password = "admin123";

安全代码:

String apiKey = System.getenv("API_KEY");
String password = keyStore.getPassword("db_password");

工具使用

SonarQube

# 启动SonarQube
docker run -d -p 9000:9000 sonarqube

# 运行扫描
sonar-scanner \
  -Dsonar.projectKey=myproject \
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000

Semgrep

# 安装
pip install semgrep

# 运行扫描
semgrep --config=auto .

# 使用规则
semgrep --config=p/security-audit .

CodeQL

# 创建数据库
codeql database create database --language=java --source-root=.

# 运行查询
codeql database analyze database security-and-quality.qls --format=sarif-latest

审查清单

输入验证

  • 所有用户输入都经过验证
  • 使用白名单验证
  • 验证数据类型和范围
  • 处理特殊字符

输出编码

  • HTML输出编码
  • URL编码
  • JavaScript编码
  • SQL参数化

认证授权

  • 强密码策略
  • 安全的会话管理
  • 权限验证
  • 多因素认证

加密

  • 使用强加密算法
  • 密钥安全存储
  • 传输加密
  • 存储加密

错误处理

  • 不泄露敏感信息
  • 统一错误响应
  • 记录错误日志
  • 异常处理

最佳实践

1. 安全编码规范

  • 遵循OWASP Top 10
  • 使用安全编码指南
  • 代码审查流程
  • 安全培训

2. 自动化工具

  • 集成SAST工具
  • CI/CD安全检查
  • 自动化扫描
  • 结果分析

3. 代码审查流程

  • 同行审查
  • 安全专家审查
  • 定期审查
  • 记录问题

注意事项

  • 结合工具和人工审查
  • 关注业务逻辑漏洞
  • 定期更新工具规则
  • 建立安全编码文化

Validation & Reporting

  • Confirm every finding with reproducible PoC before reporting
  • Document: severity (CVSS), affected asset, steps, evidence, remediation
  • Use record_vulnerability when running inside the penkit51 platform
  • Chain low-severity findings into higher-impact attack paths
  • Never report without evidence — distinguish hypothesis from confirmed vuln

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.