{"id":15292383,"url":"https://github.com/ren3gadem4rm0t/imperva-export-cli","last_synced_at":"2026-04-28T22:35:10.074Z","repository":{"id":257802389,"uuid":"861970274","full_name":"ren3gadem4rm0t/imperva-export-cli","owner":"ren3gadem4rm0t","description":"Simple cli tool for exporting Imperva CWAF account configurations as Terraform","archived":false,"fork":false,"pushed_at":"2024-09-26T22:41:55.000Z","size":38,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T10:17:42.600Z","etag":null,"topics":["cli","cwaf","go","imperva","incapsula","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ren3gadem4rm0t.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-23T19:58:16.000Z","updated_at":"2024-09-26T23:54:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d8ecec2-6844-435e-ac3b-1550cc5976f1","html_url":"https://github.com/ren3gadem4rm0t/imperva-export-cli","commit_stats":null,"previous_names":["ren3gadem4rm0t/imperva-export-cli"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ren3gadem4rm0t/imperva-export-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fimperva-export-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fimperva-export-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fimperva-export-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fimperva-export-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ren3gadem4rm0t","download_url":"https://codeload.github.com/ren3gadem4rm0t/imperva-export-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ren3gadem4rm0t%2Fimperva-export-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cwaf","go","imperva","incapsula","terraform"],"created_at":"2024-09-30T16:17:40.405Z","updated_at":"2026-04-28T22:35:10.058Z","avatar_url":"https://github.com/ren3gadem4rm0t.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Imperva Export CLI\n\n[![Build Status](https://github.com/ren3gadem4rm0t/imperva-export-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/ren3gadem4rm0t/imperva-export-cli/actions/workflows/ci.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/ren3gadem4rm0t/imperva-export-cli?sort=semver)](https://github.com/ren3gadem4rm0t/imperva-export-cli/releases)\n[![GitHub issues](https://img.shields.io/github/issues/ren3gadem4rm0t/imperva-export-cli)](https://github.com/ren3gadem4rm0t/imperva-export-cli/issues)\n[![GitHub stars](https://img.shields.io/github/stars/ren3gadem4rm0t/imperva-export-cli?style=social)](https://github.com/ren3gadem4rm0t/imperva-export-cli/stargazers)\n\u003c!-- [![Go Report Card](https://goreportcard.com/badge/github.com/ren3gadem4rm0t/imperva-export-cli)](https://goreportcard.com/report/github.com/ren3gadem4rm0t/imperva-export-cli) --\u003e\n\nThe **Imperva Export CLI** is a command-line tool designed to interact seamlessly with the Imperva Account-Export API. It facilitates the export of account configurations into ZIP files formatted for standard Terraform usage. This tool simplifies the process of exporting, monitoring, and downloading account configurations, ensuring efficient and automated management of your Imperva resources.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n  - [Commands](#commands)\n    - [Export](#export)\n    - [Download](#download)\n    - [Status](#status)\n    - [Auto](#auto)\n- [Logging](#logging)\n- [Error Handling](#error-handling)\n- [Development](#development)\n  - [Testing](#testing)\n  - [Linting](#linting)\n  - [Code Coverage](#code-coverage)\n  - [Static Analysis](#static-analysis)\n- [Contributing](#contributing)\n- [License](#license)\n- [Support](#support)\n\n## Features\n\n- **Export Account Configurations**: Initiate export processes for parent or sub-accounts.\n- **Asynchronous Operations**: Handle long-running export tasks efficiently.\n- **Status Monitoring**: Poll and monitor the status of export processes.\n- **Secure Downloads**: Safely download exported ZIP files with validation.\n- **Flexible Configuration**: Configure via environment variables, configuration files, or command-line flags.\n- **Structured Logging**: Utilize structured logging with adjustable verbosity levels.\n- **Graceful Shutdown**: Supports interrupt signals to safely terminate operations.\n- **Automated Testing**: Comprehensive test coverage ensures reliability.\n\n## Installation\n\nYou can install the Imperva Export CLI using `go install`:\n\n```bash\ngo install github.com/ren3gadem4rm0t/imperva-export-cli@latest\n```\n\n### Prerequisites\n\n- **Go**: Ensure you have Go installed (version 1.23 or later). You can download it from [Go's official website](https://golang.org/dl/).\n\n### Clone the Repository\n\n```bash\ngit clone https://github.com/ren3gadem4rm0t/imperva-export-cli.git\ncd imperva-export-cli\n```\n\n### Build the Binary\n\n```bash\ngo build -o imperva-export-cli ./main.go\n```\n\nThis command compiles the CLI tool and produces an executable named `imperva-export-cli` in the current directory.\n\n### Install via Makefile\n\nAlternatively, you can use the provided `Makefile` for building and managing the project.\n\n```bash\nmake build\n```\n\n## Configuration\n\nThe CLI tool requires authentication credentials to interact with the Imperva API. These can be provided through environment variables, a configuration file, or command-line flags.\n\n### Authentication Credentials\n\n- **API ID**: A unique identifier for your API access.\n- **API Key**: A secret key associated with your API ID.\n\n### Methods to Provide Credentials\n\n1. **Environment Variables**\n\n   Set the following environment variables:\n\n   ```bash\n   export API_ID=your-api-id\n   export API_KEY=your-api-key\n   ```\n\n2. **Configuration File**\n\n   Create a configuration file named `imperva-export-cli.yaml` in the `$HOME/.config/` directory with the following content:\n\n   ```yaml\n   api-id: your-api-id\n   api-key: your-api-key\n   log-level: info\n   output-dir: /path/to/output\n   ```\n\n3. **Command-Line Flags**\n\n   Provide credentials directly via command-line flags when executing commands:\n\n   ```bash\n   imperva-export-cli export --caid 123456 --api-id your-api-id --api-key your-api-key\n   ```\n\n### Configuration Hierarchy\n\nThe CLI prioritizes configuration sources in the following order:\n\n1. **Command-Line Flags**\n2. **Environment Variables**\n3. **Configuration File**\n4. **Defaults**\n\n### Additional Configuration Options\n\n- **Log Level**: Adjust the verbosity of logs.\n  - Flags: `--log-level`\n  - Environment Variable: `LOG_LEVEL`\n  - Options: `none`, `debug`, `info`, `warn`, `error`\n\n- **Output Directory**: Specify where exported files are saved.\n  - Flags: `--output-dir`\n  - Environment Variable: `OUTPUT_DIR`\n  - Default: Current directory (`.`)\n\n## Usage\n\nThe CLI provides several commands to manage the export process. Below are detailed descriptions and examples for each command.\n\n### Commands\n\n#### Export\n\n**Description**: Initiates the export process for a specified CAID (Customer Account ID).\n\n**Usage**:\n\n```bash\nimperva-export-cli export --caid \u003cCAID\u003e [flags]\n```\n\n**Flags**:\n\n- `--caid`: *(Required)* The account ID to export configurations for.\n- `--api-id`: API ID (optional if set via environment/config).\n- `--api-key`: API Key (optional if set via environment/config).\n- `--log-level`: Set log verbosity (`none`, `debug`, `info`, `warn`, `error`).\n- `--output-dir`: Directory to save exported files.\n\n**Example**:\n\n```bash\nimperva-export-cli export --caid 123456\n```\n\n#### Download\n\n**Description**: Downloads the exported ZIP file using the provided handler and CAID.\n\n**Usage**:\n\n```bash\nimperva-export-cli download --caid \u003cCAID\u003e --handler \u003cHANDLER\u003e [flags]\n```\n\n**Flags**:\n\n- `--caid`: *(Required)* The account ID associated with the export.\n- `--handler`: *(Required)* The handler ID received during export initiation.\n- `--api-id`: API ID (optional if set via environment/config).\n- `--api-key`: API Key (optional if set via environment/config).\n- `--log-level`: Set log verbosity (`none`, `debug`, `info`, `warn`, `error`).\n- `--output-dir`: Directory to save the downloaded file.\n\n**Example**:\n\n```bash\nimperva-export-cli download --caid 123456 --handler abc-def-ghi-jkl\n```\n\n#### Status\n\n**Description**: Checks the status of an ongoing export process using the handler and CAID.\n\n**Usage**:\n\n```bash\nimperva-export-cli status --caid \u003cCAID\u003e --handler \u003cHANDLER\u003e [flags]\n```\n\n**Flags**:\n\n- `--caid`: *(Required)* The account ID associated with the export.\n- `--handler`: *(Required)* The handler ID received during export initiation.\n- `--api-id`: API ID (optional if set via environment/config).\n- `--api-key`: API Key (optional if set via environment/config).\n- `--log-level`: Set log verbosity (`none`, `debug`, `info`, `warn`, `error`).\n\n**Example**:\n\n```bash\nimperva-export-cli status --caid 123456 --handler abc-def-ghi-jkl\n```\n\n#### Auto\n\n**Description**: Automates the entire export process by initiating the export, monitoring its status, and downloading the exported file upon completion.\n\n**Usage**:\n\n```bash\nimperva-export-cli auto --caid \u003cCAID\u003e [flags]\n```\n\n**Flags**:\n\n- `--caid`: *(Required)* The account ID to export configurations for.\n- `--api-id`: API ID (optional if set via environment/config).\n- `--api-key`: API Key (optional if set via environment/config).\n- `--log-level`: Set log verbosity (`none`, `debug`, `info`, `warn`, `error`).\n- `--output-dir`: Directory to save exported files.\n\n**Example**:\n\n```bash\nimperva-export-cli auto --caid 123456\n```\n\n### Common Flags Across Commands\n\n- `--api-id`: Provide API ID directly.\n- `--api-key`: Provide API Key directly.\n- `--log-level`: Control log verbosity.\n- `--output-dir`: Specify where to save exported files.\n\n## Logging\n\nThe Imperva Export CLI uses [zerolog](https://github.com/rs/zerolog) for structured logging. You can control the verbosity of logs using the `--log-level` flag or the `LOG_LEVEL` environment variable.\n\n**Log Levels**:\n\n- `none`: Disable all logs.\n- `debug`: Detailed debug information.\n- `info`: General operational messages.\n- `warn`: Warning messages indicating potential issues.\n- `error`: Error messages indicating failed operations.\n\n**Examples**:\n\n- **Set to Debug Level**:\n\n  ```bash\n  imperva-export-cli export --caid 123456 --log-level debug\n  ```\n\n- **Set via Environment Variable**:\n\n  ```bash\n  export LOG_LEVEL=debug\n  imperva-export-cli export --caid 123456\n  ```\n\n**Default Log Level**: `none`\n\n## Error Handling\n\nThe CLI tool provides comprehensive error messages to help diagnose issues during operations. Errors can occur due to:\n\n- **Invalid Inputs**: Incorrect CAID or handler formats.\n- **Authentication Failures**: Missing or invalid API credentials.\n- **API Errors**: Issues returned by the Imperva API, such as rate limiting or server errors.\n- **Network Issues**: Connectivity problems during API requests.\n- **File System Errors**: Issues with writing or saving exported files.\n\n**Best Practices**:\n\n- Ensure that the CAID and handler provided are correct and correspond to existing accounts/export processes.\n- Verify that API credentials (`API_ID` and `API_KEY`) are valid and have the necessary permissions.\n- Check network connectivity if experiencing persistent errors during API requests.\n- Ensure that the specified output directory is writable and has sufficient space.\n\n**Example Error Message**:\n\n```bash\nError: failed to initiate export: API error: Authentication Error - Authentication missing or invalid (Status Code: 401)\n```\n\n## Development\n\n### Prerequisites\n\n- **Go**: Version 1.23 or later.\n- **Make**: For using the provided `Makefile`.\n- **Static Analysis Tools**: Optional but recommended (e.g., `golangci-lint`, `gosec`).\n\n### Building the Project\n\nUse the `Makefile` for streamlined building and managing the project.\n\n- **Build the Project**:\n\n  ```bash\n  make build\n  ```\n\n- **Run Tests**:\n\n  ```bash\n  make test\n  ```\n\n- **Run Linting**:\n\n  ```bash\n  make lint\n  ```\n\n- **Format Code**:\n\n  ```bash\n  make fmt\n  ```\n\n- **Check Code Formatting**:\n\n  ```bash\n  make check-fmt\n  ```\n\n- **Run Static Analysis**:\n\n  ```bash\n  make staticcheck\n  make ast\n  ```\n\n- **Generate Coverage Report**:\n\n  ```bash\n  make coverage\n  ```\n\n- **Clean Build Artifacts**:\n\n  ```bash\n  make clean\n  ```\n\n### Testing\n\nThe project includes comprehensive unit tests covering various components and scenarios.\n\n- **Run All Tests**:\n\n  ```bash\n  make test\n  ```\n\n- **View Test Coverage**:\n\n  ```bash\n  make coverage\n  ```\n\nCoverage reports are generated in the `coverage/` directory and can be viewed in HTML format.\n\n### Linting\n\nEnsure code quality and adherence to best practices using `golangci-lint`.\n\n- **Run Linting**:\n\n  ```bash\n  make lint\n  ```\n\n### Code Coverage\n\nMonitor test coverage to ensure critical paths are tested.\n\n- **Generate Coverage Report**:\n\n  ```bash\n  make coverage\n  ```\n\n- **View Coverage in Browser**:\n\n  The coverage report is saved as `coverage/coverage.html` and can be opened in a web browser.\n\n### Static Analysis\n\nPerform security and static code analysis using tools like `gosec` and `staticcheck`.\n\n- **Run GoSec**:\n\n  ```bash\n  make ast\n  ```\n\n- **Run StaticCheck**:\n\n  ```bash\n  make staticcheck\n  ```\n\n### Documentation\n\nGenerate and view documentation using `godoc`.\n\n- **Start Godoc Server**:\n\n  ```bash\n  make docs\n  ```\n\n  Access the documentation at [http://localhost:6060/pkg/github.com/ren3gadem4rm0t/imperva-export-cli/internal/cmd/](http://localhost:6060/pkg/github.com/ren3gadem4rm0t/imperva-export-cli/internal/cmd/)\n\n## Contributing\n\nContributions are welcome! Please follow the guidelines below to contribute to the project.\n\n### Guidelines\n\n1. **Fork the Repository**: Create a personal fork of the repository.\n2. **Clone Your Fork**:\n\n   ```bash\n   git clone https://github.com/your-username/imperva-export-cli.git\n   cd imperva-export-cli\n   ```\n\n3. **Create a New Branch**:\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n4. **Make Changes**: Implement your feature or fix.\n5. **Run Tests and Linting**:\n\n   ```bash\n   make test\n   make lint\n   ```\n\n6. **Commit Changes**:\n\n   ```bash\n   git commit -m \"Add feature: your feature description\"\n   ```\n\n7. **Push to Your Fork**:\n\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n8. **Create a Pull Request**: Submit a pull request through GitHub.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Support\n\nIf you encounter any issues or have questions, please open an issue on the [GitHub repository](https://github.com/ren3gadem4rm0t/imperva-export-cli/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fren3gadem4rm0t%2Fimperva-export-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fren3gadem4rm0t%2Fimperva-export-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fren3gadem4rm0t%2Fimperva-export-cli/lists"}