feat: поддержка Go и npm экосистем

- setup-nexus.sh: создание go-proxy (proxy.golang.org) и npm-proxy (registry.npmjs.org)
- nexus_client.py: extract_go_info() и extract_npm_info() для парсинга путей
  Go:  packages/github.com/gorilla/mux/@v/v1.8.0.zip → name=github.com/gorilla/mux ver=v1.8.0
  npm: packages/lodash/-/lodash-4.17.21.tgz → name=lodash ver=4.17.21
- nexus_client.py: EXTRACTORS dict + extract_package_info() универсальный extractor
- webhooks.py: _detect_ecosystem() — определяет экосистему из asset.format
- harvester.py: использует extract_package_info() вместо extract_pypi_info()
- Всё в Docker-контейнере, на хосте ничего не ставится
- GuardDog поддерживает go и npm из коробки
This commit is contained in:
Marker689
2026-05-10 06:29:34 +03:00
parent 646a50d01a
commit 6523f55dcd
5 changed files with 134 additions and 40 deletions

View File

@@ -30,37 +30,51 @@ if [ -f /nexus-data/admin.password ]; then
echo "Using initial admin password from volume"
fi
echo "Creating PyPI proxy repository..."
curl -sf -u "admin:${AUTH_PASS}" \
-H "Content-Type: application/json" \
-X POST \
-d "{
\"name\": \"pypi-proxy\",
\"online\": true,
\"storage\": {
\"blobStoreName\": \"default\",
\"strictContentTypeValidation\": true
},
\"proxy\": {
\"remoteUrl\": \"https://pypi.org\",
\"contentMaxAge\": 1440,
\"metadataMaxAge\": 1440
},
\"negativeCache\": {
\"enabled\": true,
\"timeToLive\": 1440
},
\"httpClient\": {
\"blocked\": false,
\"autoBlock\": true,
\"connection\": {
\"timeout\": 60,
\"retries\": 3
}
# Common proxy config
_proxy_config() {
cat <<EOF
{
"name": "$1",
"online": true,
"storage": {
"blobStoreName": "default",
"strictContentTypeValidation": true
},
"proxy": {
"remoteUrl": "$2",
"contentMaxAge": 1440,
"metadataMaxAge": 1440
},
"negativeCache": {
"enabled": true,
"timeToLive": 1440
},
"httpClient": {
"blocked": false,
"autoBlock": true,
"connection": {
"timeout": 60,
"retries": 3
}
}" \
"${NEXUS_URL}/service/rest/v1/repositories/pypi/proxy" 2>/dev/null || \
echo "Proxy repo may already exist, continuing..."
}
}
EOF
}
_create_proxy() {
local name="$1" remote="$2" format="$3"
echo "Creating $name ($format proxy → $remote)..."
curl -sf -u "admin:${AUTH_PASS}" \
-H "Content-Type: application/json" \
-X POST \
-d "$(_proxy_config "$name" "$remote")" \
"${NEXUS_URL}/service/rest/v1/repositories/${format}/proxy" 2>/dev/null && \
echo " OK" || echo " already exists or failed, continuing..."
}
_create_proxy "pypi-proxy" "https://pypi.org" "pypi"
_create_proxy "go-proxy" "https://proxy.golang.org" "go"
_create_proxy "npm-proxy" "https://registry.npmjs.org" "npm"
echo ""
echo "NOTE: Webhook setup is not available in Nexus OSS/Community edition."
@@ -68,7 +82,7 @@ echo "In Nexus Pro, configure:"
echo " Capability: Webhook: Repository"
echo " URL: ${WEBHOOK_URL}"
echo " Event types: repository.component, repository.asset"
echo " Repository filter: pypi-proxy"
echo " Repository filter: pypi-proxy, go-proxy, npm-proxy"
echo ""
if [ -f /nexus-data/admin.password ]; then