Metadata-Version: 2.4
Name: damv1springbootvalidator-forscriptspipeline
Version: 1.0.0
Summary: A secure, Cython-compiled Spring Boot config validator for CI/CD pipelines.
Author: dhonyabumuhammad (Djogja)
Author-email: baba-rtw24150@tutamail.com
Keywords: spring-boot,ci-cd,validator,pipeline,cython,obfuscation,bitbucket
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Cython
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Security
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: keywords
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

## damv1springbootvalidator_forscriptspipeline

A specialized, **Cython-compiled** Python package that validates Spring Boot configuration files (`application.yml` / `application.properties`) as a CI/CD deployment gatekeeper. Enforces dynamic placeholder usage (`${VAR}` / `${VAR:default}`) on sensitive configuration paths such as Flyway flags and JDBC connection strings.

### Overview

This package provides a robust command-line validator for CI/CD pipelines. It detects Spring Boot projects (Maven/Gradle), resolves active Spring profiles, and validates that configured paths use dynamic placeholders instead of hardcoded values (hostnames, IPs, ports, database names). It supports non-blocking mode and Telegram failure notifications with automatic CI/CD metadata detection.

**Security Enhancement (v1.0.0+):** Core logic is compiled into C-extensions (`.so` / `.pyd`), preventing easy reverse-engineering or unauthorized modification of the validation logic.

### Key Features

- **Multi-Entry Validation**: `--require-placeholder`, `--strict-placeholder` (optional-strict), `--optional-placeholder`.
- **Strict URL Template Validation**: Detects hardcoded hostname, IP address, port, and database/schema name inside connection strings.
- **Active Profile Resolution**: Validates base config plus active profile-specific files with correct override priority.
- **Ignore-Fail Mode**: `--ignore-fail-all-require-placeholder` lets the pipeline continue while still reporting failures.
- **Telegram Notification**: `--notification-fail-validation` with auto-detected project name, repository, build number, and pipeline link (Bitbucket). Graceful fallback if credentials are invalid.
- **Source Code Obfuscation**: Compiled via Cython.
- **Professional Log Output**: No emojis, ASCII table report, CI-friendly exit codes.

### Platform Compatibility Warning

Due to Cython compilation, this package is **architecture and OS-specific**.

- A wheel built for **Linux x86_64** will ONLY run on Linux x86_64.
- A wheel built for **macOS ARM64** will ONLY run on macOS ARM64 (Apple Silicon).
- Distribution wheels are built via a `cibuildwheel` matrix: Linux `x86_64` + `aarch64`, macOS `arm64`, Windows `AMD64`.

### Installation

From production PyPI:

```bash
pip install damv1springbootvalidator-forscriptspipeline
```

From TestPyPI (staging verification; `--extra-index-url` required because the `PyYAML` dependency lives on production PyPI):

```bash
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple damv1springbootvalidator-forscriptspipeline
```

### CLI Syntax

```bash
damv1springbootvalidator_forscriptspipeline \
  [--require-placeholder PATH [PATH ...]] \
  [--strict-placeholder PATH [PATH ...]] \
  [--optional-placeholder PATH [PATH ...]] \
  [--ignore-fail-all-require-placeholder] \
  [--notification-fail-validation] \
  [--teleg-bot TOKEN] [--teleg-chat-id CHAT_ID]
```

#### Parameters

| Parameter | Description |
|---|---|
| `--require-placeholder` | Paths that MUST exist and MUST contain a `${...}` placeholder. |
| `--strict-placeholder` | If the path exists, ALL dynamic parts must be placeholders (no hardcoded host/port/db). If absent, SKIP (pass). |
| `--optional-placeholder` | Checked only if the path exists. |
| `--ignore-fail-all-require-placeholder` | Exit code 0 even when validations fail (non-blocking pipeline). |
| `--notification-fail-validation` | Send Telegram notification when failures exist. |
| `--teleg-bot` | Telegram bot token. Invalid/empty value only logs a warning, never fails the process. |
| `--teleg-chat-id` | Telegram chat ID. |

#### Exit Codes

| Code | Meaning |
|---|---|
| `0` | All validations passed, OR failures ignored via `--ignore-fail-all-require-placeholder`. |
| `1` | Validation failed and process halted. |

### Usage Example 1: Bitbucket Pipeline (Linux x86_64)

```yaml
image: maven:3-openjdk-17

pipelines:
  default:
    - step:
        name: '1. Validate Spring Boot Configs (Cython Secured)'
        image: python:3.10-slim
        script:
          - pip install --upgrade pip
          - PKG="damv1springbootvalidator-forscriptspipeline${PKGVALIDATOR_VERSION:+==${PKGVALIDATOR_VERSION}}"
          - pip install "$PKG"
          - |
            damv1springbootvalidator_forscriptspipeline \
              --require-placeholder spring.flyway.enabled \
              --strict-placeholder spring.datasource.url spring.datasource.writer.url \
              --optional-placeholder aws.athena.workgroup \
              --ignore-fail-all-require-placeholder \
              --notification-fail-validation \
              --teleg-bot "${TELEGRAM_BOT_TOKEN}" \
              --teleg-chat-id "${TELEGRAM_CHAT_ID}"

    - step:
        name: '2. Build & Test'
        script:
          - mvn clean package
```

Store `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID` in **Repository Variables** (masked). The validator auto-detects `BITBUCKET_REPO_SLUG`, `BITBUCKET_BUILD_NUMBER`, and `BITBUCKET_PIPELINE_UUID` for the notification.

### Usage Example 2: Local Simulation on macOS (Darwin ARM64 / Apple Silicon)

```bash
# Verify architecture (expect: arm64)
python3 -c "import platform; print(platform.machine())"

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip

# From TestPyPI (staging) or production PyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple damv1springbootvalidator-forscriptspipeline

cd spring-build
damv1springbootvalidator_forscriptspipeline \
  --require-placeholder spring.flyway.enabled \
  --strict-placeholder spring.datasource.url spring.datasource.writer.url \
  --optional-placeholder aws.athena.workgroup
echo "Exit code: $?"
```

### Usage Example 3: Local Simulation on Linux x86_64 (Docker)

```bash
docker run --rm -it -v "$(pwd)":/work -w /work python:3.10-slim bash

# Inside container (verify architecture, expect: x86_64)
uname -m
pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple damv1springbootvalidator-forscriptspipeline

cd spring-build
damv1springbootvalidator_forscriptspipeline \
  --require-placeholder spring.flyway.enabled \
  --strict-placeholder spring.datasource.url
echo "Exit code: $?"
```

### Sample Output

```text
[STEP 1: SPRING BOOT PROJECT DETECTION]
[OK] Spring Boot Maven Application detected

[STEP 2: CONFIGURATION SCAN]
[SCAN] Base: ./src/main/resources/application.yaml
[SCAN] Active profiles: None (base only)

Files to validate:
  1. ./src/main/resources/application.yaml

[REPORT]
  PATH                          | STATUS | DETAILS
  ------------------------------+--------+-----------------------------------
  spring.flyway.enabled         | OK     | placeholder: FLYWAY_ENABLED
  spring.datasource.url         | OK     | placeholder: POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB [strict-ok]
  spring.datasource.writer.url  | SKIP   | not present (strict-optional)

[SUMMARY]
Project             : spring-build
Project Source      : git remote origin
Total paths checked : 3
Passed              : 2
Failed              : 0
Skipped             : 1

Environment variables required:
  - FLYWAY_ENABLED
  - POSTGRES_DB
  - POSTGRES_HOST
  - POSTGRES_PORT

[RESULT] ALL VALIDATIONS PASSED
```

### Sample Telegram Notification (HTML formatted)

```text
SPRING BOOT CONFIG VALIDATION ALERT

Source: spring_boot_validator
Project: spring-build (git remote origin)
Status: FAILED (IGNORED)

Failed Validations (1):
- spring.flyway.enabled
  reason: HARDCODED: 'True' [application.yaml]

Note: pipeline will CONTINUE,
failures ignored via --ignore-fail-all-require-placeholder.

View Pipeline Result
```

### Maintainer

- **Author**: dhonyabumuhammad (Djogja)
- **Contact**: baba-rtw24150@tutamail.com
- **Version**: 1.0.0 (Cython Secured)
