Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ Prowler is an open-source cloud security assessment tool supporting AWS, Azure,
```bash
# Setup
poetry install --with dev
poetry run pre-commit install
poetry run prek install

# Code quality
poetry run make lint
poetry run make format
poetry run pre-commit run --all-files
poetry run prek run --all-files
```

---
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,7 @@ Some pre-commit hooks require tools installed on your system:

1. **Install [TruffleHog](https://github.com/trufflesecurity/trufflehog#install)** (secret scanning) — see the [official installation options](https://github.com/trufflesecurity/trufflehog#install).

2. **Install [Safety](https://github.com/pyupio/safety)** (dependency vulnerability checking):

```console
# Requires a Python environment (e.g. via pyenv)
pip install safety
```

3. **Install [Hadolint](https://github.com/hadolint/hadolint#install)** (Dockerfile linting) — see the [official installation options](https://github.com/hadolint/hadolint#install).
2. **Install [Hadolint](https://github.com/hadolint/hadolint#install)** (Dockerfile linting) — see the [official installation options](https://github.com/hadolint/hadolint#install).

## Prowler CLI
### Pip package
Expand Down
10 changes: 7 additions & 3 deletions docs/developer-guide/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,22 @@ In case you have any doubts, consult the [Poetry environment activation guide](h

### Pre-Commit Hooks

This repository uses Git pre-commit hooks managed by the [pre-commit](https://pre-commit.com/) tool, it is installed with `poetry install --with dev`. Next, run the following command in the root of this repository:
This repository uses Git pre-commit hooks managed by the [prek](https://prek.j178.dev/) tool, it is installed with `poetry install --with dev`. Next, run the following command in the root of this repository:

```shell
pre-commit install
prek install
```

Successful installation should produce the following output:

```shell
pre-commit installed at .git/hooks/pre-commit
prek installed at `.git/hooks/pre-commit`
```

<Warning>
If pre-commit hooks were previously installed, run `prek install --overwrite` to replace the existing hook. Otherwise, both tools will run on each commit.
</Warning>

### Code Quality and Security Checks

Before merging pull requests, several automated checks and utilities ensure code security and updated dependencies:
Expand Down
118 changes: 27 additions & 91 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mock = "5.2.0"
moto = {extras = ["all"], version = "5.1.11"}
openapi-schema-validator = "0.6.3"
openapi-spec-validator = "0.7.1"
pre-commit = "4.2.0"
prek = "0.3.8"
pylint = "3.3.4"
pytest = "8.3.5"
pytest-cov = "6.0.0"
Expand Down
66 changes: 37 additions & 29 deletions scripts/setup-git-hooks.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

# Setup Git Hooks for Prowler
# This script installs pre-commit hooks using the project's Poetry environment
# This script installs prek hooks using the project's Poetry environment
# or a system-wide prek installation

set -e

Expand All @@ -23,43 +24,50 @@ if ! git rev-parse --git-dir >/dev/null 2>&1; then
exit 1
fi

# Check if Poetry is installed
if ! command -v poetry &>/dev/null; then
echo -e "${RED}❌ Poetry is not installed${NC}"
echo -e "${YELLOW} Install Poetry: https://python-poetry.org/docs/#installation${NC}"
exit 1
fi

# Check if pyproject.toml exists
if [ ! -f "pyproject.toml" ]; then
echo -e "${RED}❌ pyproject.toml not found${NC}"
echo -e "${YELLOW} Please run this script from the repository root${NC}"
exit 1
fi

# Check if dependencies are already installed
if ! poetry run python -c "import pre_commit" 2>/dev/null; then
echo -e "${YELLOW}📦 Installing project dependencies (including pre-commit)...${NC}"
poetry install --with dev
else
echo -e "${GREEN}✓${NC} Dependencies already installed"
fi

echo ""
# Clear any existing core.hooksPath to avoid pre-commit conflicts
# Clear any existing core.hooksPath to avoid conflicts
if git config --get core.hooksPath >/dev/null 2>&1; then
echo -e "${YELLOW}🧹 Clearing existing core.hooksPath configuration...${NC}"
git config --unset-all core.hooksPath
fi

echo -e "${YELLOW}🔗 Installing pre-commit hooks...${NC}"
poetry run pre-commit install
echo ""

# Full setup requires Poetry for system hooks (pylint, bandit, safety, vulture, trufflehog)
# These are installed as Python dev dependencies and used by local hooks in .pre-commit-config.yaml
if command -v poetry &>/dev/null && [ -f "pyproject.toml" ]; then
if poetry run prek --version &>/dev/null 2>&1; then
echo -e "${GREEN}✓${NC} prek and dependencies found via Poetry"
else
echo -e "${YELLOW}📦 Installing project dependencies (including prek)...${NC}"
poetry install --with dev
fi
echo -e "${YELLOW}🔗 Installing prek hooks...${NC}"
poetry run prek install --overwrite
elif command -v prek &>/dev/null; then
# prek is available system-wide but without Poetry dev deps
echo -e "${GREEN}✓${NC} prek found in PATH"
echo -e "${YELLOW}🔗 Installing prek hooks...${NC}"
prek install --overwrite
echo ""
echo -e "${YELLOW}⚠️ Warning: Some hooks require Python tools installed via Poetry:${NC}"
echo -e " pylint, bandit, safety, vulture, trufflehog"
echo -e " These hooks will be skipped unless you install them or run:"
echo -e " ${GREEN}poetry install --with dev${NC}"
else
echo -e "${RED}❌ prek is not installed${NC}"
echo -e "${YELLOW} Install prek using one of these methods:${NC}"
echo -e " • brew install prek"
echo -e " • pnpm add -g @j178/prek"
echo -e " • pip install prek"
echo -e " • See https://prek.j178.dev/installation/ for more options"
exit 1
fi

echo ""
echo -e "${GREEN}✅ Git hooks successfully configured!${NC}"
echo ""
echo -e "${YELLOW}📋 Pre-commit system:${NC}"
echo -e " • Python pre-commit manages all git hooks"
echo -e "${YELLOW}📋 Prek hook system:${NC}"
echo -e " • Prek manages all git hooks"
echo -e " • API files: Python checks (black, flake8, bandit, etc.)"
echo -e " • UI files: UI checks (TypeScript, ESLint, Claude Code validation)"
echo ""
Expand Down
10 changes: 5 additions & 5 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ Or remove the variable from your `.env` file.

### Troubleshooting

If hooks aren't running after commits:
If hooks aren't running after commits, verify prek is installed and hooks are set up:

```bash
# Verify hooks are configured
git config --get core.hooksPath # Should output: ui/.husky
# Check prek is available
prek --version

# Reconfigure if needed
git config core.hooksPath "ui/.husky"
# Re-install hooks if needed
prek install --overwrite
```
4 changes: 2 additions & 2 deletions ui/docs/code-review/CODE_REVIEW_SETUP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Review Setup - Prowler UI

Guide to set up automatic code validation with Claude Code in the pre-commit hook.
Guide to set up automatic code validation with Claude Code in the commit hook.

## Overview

Expand Down Expand Up @@ -35,7 +35,7 @@ In `/ui/.env`, find the "Code Review Configuration" section:

```bash
#### Code Review Configuration ####
# Enable Claude Code standards validation on pre-commit hook
# Enable Claude Code standards validation on commit hook
# Set to 'true' to validate changes against AGENTS.md standards via Claude Code
# Set to 'false' to skip validation
CODE_REVIEW_ENABLED=false # ← Change this to 'true'
Expand Down
2 changes: 1 addition & 1 deletion ui/docs/code-review/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Review System Documentation

Complete documentation for the Claude Code-powered pre-commit validation system.
Complete documentation for the Claude Code-powered commit validation system.

## Quick Navigation

Expand Down
Loading
Loading