Skip to content

Commit

Permalink
Merge pull request #199 from carlosmmatos/fix-pypi-package
Browse files Browse the repository at this point in the history
fix: make pip package actually work
carlosmmatos authored Dec 20, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
2 parents d32820a + 942d7e7 commit f55d27e
Showing 5 changed files with 75 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,3 +6,5 @@
/config/devel.ini
/runtest.sh
*.DS_Store
/build
/dist
61 changes: 55 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,11 @@ Detection findings and audit events generated by CrowdStrike Falcon platform inf

This project facilitates the export of the individual detections and audit events from CrowdStrike Falcon to third-party security dashboards (so called backends). The export is useful in cases where security operation team workflows are tied to given third-party solution to get early real-time heads-up about malicious activities or unusual user activities detected by CrowdStrike Falcon platform.

## Python Compatibility

> [!IMPORTANT]
> Compatible with Python versions 3.7 through 3.11
## API Scopes

API clients are granted one or more API scopes. Scopes allow access to specific CrowdStrike APIs and describe the actions that an API client can perform.
@@ -137,37 +142,81 @@ To install as a container:
docker logs <container>
```

### From the Python Package Index (PyPI)

> [!IMPORTANT]
> Falcon Integration Gateway (FIG) versions below 3.2.1 on PyPI are broken and will not install correctly. Please ensure you install version 3.2.1 or higher from PyPI.

1. Install the package using pip:

```bash
python3 -m pip install falcon-integration-gateway
```

1. Once installed, create a configuration file or set your environment variables according to the [CONFIG](./config/config.ini) options before running the application. Example `config.ini` for the GENERIC backend:

```ini
[main]
backends = GENERIC
[events]
older_than_days_threshold = 5
[logging]
level = DEBUG
[falcon]
cloud_region = us-1
client_id = ABCD
client_secret = ABCD
application_id = my-generic-id
```

1. Run the application:

```bash
python3 -m fig
```

#### Updating the FIG from PyPI

To update the FIG package from PyPI, run:

```bash
python3 -m pip install --upgrade falcon-integration-gateway
```

### From Git Repository

> [!NOTE]
> This method requires Python 3.7 or higher and a python package manager such as `pip` to be installed on your system.

1. Clone and navigate to the repository
1. Clone and navigate to the repository:

```bash
git clone https://github.com/CrowdStrike/falcon-integration-gateway.git
cd falcon-integration-gateway
```

1. Install the python dependencies.
1. Install the python dependencies:

```bash
pip3 install -r requirements.txt
python3 -m pip install -r requirements.txt
```

1. Modify the `./config/config.ini` file with your configuration options or set the associated environment variables.

1. Run the application
1. Run the application:

```bash
python3 -m fig
```

### Updating the FIG from the Git Repository
#### Updating the FIG from the Git Repository

Depending on which configuration method you are using, follow the steps below to update the FIG from the Git repository.

#### config.ini
##### config.ini

If you have made any changes to the `config.ini` file, you can update the FIG by following these steps:

16 changes: 15 additions & 1 deletion fig/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import configparser
from functools import cached_property
from importlib.resources import files
from .credstore import CredStore


@@ -44,10 +45,23 @@ class FigConfig(configparser.ConfigParser):

def __init__(self):
super().__init__()
self.read(['config/defaults.ini', 'config/config.ini', 'config/devel.ini'])
self._read_config_files()
self._override_from_env()
self._override_from_credentials_store()

def _read_config_files(self):
# If installed via python package, look for defaults.ini in package directory
default_config = files('config').joinpath('defaults.ini')
self.read(default_config)
# Allow overrides from local directory and config directory
config_files = ['defaults.ini', 'config.ini', 'devel.ini']
for file in config_files:
# Try reading from local directory first, then from config directory
if os.path.exists(file):
self.read(file)
elif os.path.exists(os.path.join('config', file)):
self.read(os.path.join('config', file))

def _override_from_env(self):
for section, var, envvar in self.__class__.ENV_DEFAULTS:
value = os.getenv(envvar)
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from setuptools import find_packages
from setuptools import setup
from glob import glob
from os.path import basename
from os.path import splitext
import fig

with open("README.md", "r") as fh:
@@ -17,9 +14,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/crowdstrike/falcon-integration-gateway",
packages=find_packages("fig"),
package_dir={"": "fig"},
py_modules=[splitext(basename(path))[0] for path in glob("fig/*.py")],
packages=find_packages(),
include_package_data=True,
install_requires=[
'boto3',
@@ -49,5 +44,5 @@
"License :: OSI Approved :: The Unlicense (Unlicense)",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
python_requires='>=3.6, <3.12'
)

0 comments on commit f55d27e

Please sign in to comment.