360 Secure SkillHub
360 安全技能中心

Maven Pom Validator

该 Skill 通过 scripts/maven_pom_validator.py 对 Maven pom.xml 执行 lint、dependencies、plugins、validate 检查,覆盖结构、依赖、插件和最佳实践规则,支持 text/json/markdown 输出与 --strict CI 模式,仅使用 Python 标准库,不下载依赖也不修改文件。

charlie-morrison
charlie-morrison
热度 52.56
最近更新 2026-05-11 17:42:55
分类:开发依赖:代码执行 / 读写文件应用场景:代码审查 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add maven-pom-validator
Metadata
name
maven-pom-validator
description
Validate and lint Maven pom.xml files for structure, dependencies, plugins, and best practices. Use when asked to lint, validate, check, or audit pom.xml files, verify Maven configuration, or ensure POM quality. Triggers on "lint pom", "validate pom.xml", "check maven", "maven best practices".

Maven POM Validator

Validate and lint Maven pom.xml files for structural correctness, dependency hygiene, plugin configuration, and best practices.

Commands

lint — Full lint pass (all 20+ rules)

python3 scripts/maven_pom_validator.py lint pom.xml
python3 scripts/maven_pom_validator.py lint pom.xml --strict
python3 scripts/maven_pom_validator.py lint pom.xml --format json
python3 scripts/maven_pom_validator.py lint pom.xml --format markdown

dependencies — Audit dependency declarations

python3 scripts/maven_pom_validator.py dependencies pom.xml
python3 scripts/maven_pom_validator.py dependencies pom.xml --format json

plugins — Audit plugin declarations

python3 scripts/maven_pom_validator.py plugins pom.xml
python3 scripts/maven_pom_validator.py plugins pom.xml --format markdown

validate — Quick structural validation only

python3 scripts/maven_pom_validator.py validate pom.xml
python3 scripts/maven_pom_validator.py validate pom.xml --strict

Flags

Flag Description
--strict Exit code 1 on warnings (CI mode)
--format text Human-readable output (default)
--format json Machine-readable JSON
--format markdown Markdown report

Lint Rules

Structure (5 rules)

  1. Valid XML — file must be well-formed XML
  2. Required elements — groupId, artifactId, version, modelVersion must be present
  3. modelVersion must be "4.0.0"
  4. groupId format — must follow reverse-domain convention (e.g. com.example)
  5. packaging value must be valid (jar, war, pom, ear, rar, maven-plugin)

Dependencies (6 rules)

  1. No duplicate dependencies (same groupId:artifactId)
  2. No SNAPSHOT versions in release POMs
  3. Version must be defined (not missing)
  4. No wildcard/range versions (LATEST, RELEASE, [1.0,))
  5. Scope must be valid (compile, test, provided, runtime, system, import)
  6. system-scoped deps must have <systemPath>

Plugins (5 rules)

  1. Plugin versions must be pinned
  2. No duplicate plugins (same groupId:artifactId)
  3. Plugin groupId should be specified
  4. Known deprecated plugins flagged
  5. Configuration elements checked for common issues

Best Practices (6 rules)

  1. Properties used for version management (DRY check)
  2. dependencyManagement used in parent POMs
  3. UTF-8 encoding specified (project.build.sourceEncoding)
  4. Java source/target version set (maven.compiler.source/target or release)
  5. No hardcoded absolute paths in configuration
  6. SCM section present

Exit Codes

Code Meaning
0 No errors (warnings OK unless --strict)
1 Errors found (or warnings with --strict)
2 Script usage error