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
89 changes: 88 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,88 @@
# Sysdig
# Sysdig Secure connector

This Connector fetch's the SecureEvents data and Audit Events data from the Sysdig Platform and stores the data locally in a JSON file.

## Steps to run the connector

- Step 1: Install the virtual environment using the following command in the command prompt/terminal:

`python -m venv <virtual_env_name>`
p
- Step 2: Enable a virtual environment.
- For Windows: Use the below command (without the word source) in the command prompt to activate the virtual environment.

`venv\Scripts\activate`

- For Linux/Mac/Ubuntu: Use the below command in the terminal to activate the virtual environment.

`source venv\bin\activate`

- Step 3: Install the required libraries by executing the below command.

`pip install -r requirements.txt`

- Step 4: Configurations.
- Provide the access token, Sysdig URL, limit,start timestamp,end timestamp and store_filename in `configs.yaml` file.

- Step 5: Execute the below command in the terminal to set up the python environment for the execution of the connector.

`python setup.py develop`

- Step 6: Execute the below command in the terminal to start the connector.

`python connector.py configs.yaml`


## How to provide the required file base_url,access_token,from,to and store_filename in the configs.yaml file.
```yaml
SecureEvents_connector :
base_url :
access_token :
from :
to :
store_filename :

### Example
Note:
from is start date in nanosecods
to is end date in nanosecods

SecureEvents_connector :
base_url :
access_token :
from : 1666675800000000000
to : 1667367000000000000
store_filename : SecureEvents_connector

```

## Sysdig Plugin connector.py file.
This performs the following actions:
- Initialize the logging module
- Read the configs file and get the required configurations
- Initialize the ResponseData object with its necessary configurations
- Collects and stores the event's data in the local device.

## Sysdig Plugin Controller Module

### controller.auth
- It provides an access token to access the APIs.

### controller.client
- Helps in making normal requests and paginated requests with SecureEvents_connector APIs.
- Paginated request's responses are stored in a JSON file in the local connector directory of the device.

### controller.data
- Provides the access token
- Get the Secure events and audit events data
- Store the responses in respective files and get the count of the responses.

## Sysdig Plugin Utils Module

### utils.general
General purpose utilities for Sysdig Plugin.
Following are the utilities:

- Create the logging object.
- Read the YAML configurations.
- Dump the received data in a JSON file.
7 changes: 7 additions & 0 deletions configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
secureEvents_connector :
base_url :
access_token :
from : 1666675800000000000
to : 1667367000000000000
limit: 10
store_filename : Sysdig
44 changes: 44 additions & 0 deletions connector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""SysDig Connector module.

SysDig Plugin Connector performs the following actions:
- Initialize the logging module
- Read the configs file and get the required configurations
- Initialize the ResponseData object with its necessary configurations
- Collects and stores the Secure Event's and Audit Event's data in local device.
"""

import sys

from secureEvents_connector.controller.data import ResponseData
from secureEvents_connector.utils.general import read_yaml, set_logger

if __name__ == "__main__":

LOG_FILENAME = "secureEvents_connector.log"
# Get the logger object
logger = set_logger(LOG_FILENAME)

CONFIGS_FILEPATH = sys.argv[1]

logger.info(f"Reading the config file : {CONFIGS_FILEPATH}")
configs = read_yaml(CONFIGS_FILEPATH)
logger.info(f"Got the configs from {CONFIGS_FILEPATH}")

base_url: str = configs["secureEvents_connector"]["base_url"]
filename: str = configs["secureEvents_connector"]["store_filename"]
access_token = configs["secureEvents_connector"]["access_token"]
response = ResponseData(
access_token,
base_url=base_url,
start_time=configs["secureEvents_connector"]["from"],
end_time=configs["secureEvents_connector"]["to"],
logger=logger,
)

logger.info("Starting to get list of SecureEvents")
SecureEvents_connector_count = response.get_secure_events_count(filename=filename)
logger.info(f"Got the Secure events count which is {SecureEvents_connector_count}")

logger.info("Starting to get list of audit activity events")
activityaudit_count = response.get_activityaudit_events_count(filename=filename)
logger.info(f"Got the audit activity events count which is {activityaudit_count}")
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyYAML==6.0
requests==2.27.1
166 changes: 166 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
[metadata]
name = SysDig_connector
version = 1.0.0
#url = https://github.com/deepakb-sacumen/hunters.io.git
license = Private
author = Sacumen
author_email = gauri.indani@sacumen.com
maintainer = Sacumen
maintainer_email = deepak.baraik@sacumen.com
description = Connector to connect to Target system, get events and store it an file locally.
long_description = file: README.rst
long_description_content_type = text/x-rst
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Topic :: Software Development :: Libraries
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy


[options]
package_dir =
= src
packages = find:
include_package_data = true
zip_safe = false
python_requires = >= 3.6
bdist_wheel =
universal = false

[options.packages.find]
where = src

[tool:pytest]
testpaths = tests
filterwarnings =
error

[coverage:run]
branch = True
source =
src/
tests

[coverage:paths]
source =
src/

[coverage:report]
fail_under = 80
precision = 2
show_missing = True
skip_covered = True

[poetry]
name= isort
description= "This hook runs isort."
entry= isort
language= python
files= \.py$

[flake8]
max-line-length = 200
max-complexity = 12
select = B,C,E,F,W,B9,B950,ISC
exclude = .venv/, tests/*
extend-ignore = E501
extend-select = B950
extend-immutable-calls = pathlib.Path, Path
import-order-style = google
application-package-names = SecureEvents, connector
application-import-names = SecureEvents, connector

[flake8:local-plugins]
paths = .

[pydocstyle]
match = (?!test_).*\.py
match_dir = ^(?!(.venv|old|tests).*)

[pyupgrade]
args = py36-plus

[pre-commit-hooks]
autofix = True
maxkb = 500
allow-multiple-documents = True
exclude= ^tests/.+/profiles.d/.*

[bandit]
exclude = tests

[pylint]
ignore = tests
persistent = no
load-plugins = pylint_common, pylint_flask, pylint_plugin_utils
unsafe-load-any-extension = no
max-line-length = 200
output-format = colorized

[pylint.messages_control]
disable = C0411,E0401,F0401,R0902,W0212,W0105,W0107,C0415

[pylint.similarities]
min-similarity-lines=4
ignore-comments=yes
ignore-docstrings=yes
ignore-imports=no

[pylint.imports]
allow-wildcard-with-all=no

[pylint.designs]
max-args=7
max-attributes=7
max-bool-expr=5
max-branches=10
max-locals=15
max-parents=7
max-public-methods=20
max-returns=4
max-statements=50
min-public-methods=2

[xenon]
max-average=A
max-modules=B
max-absolute=C
exclude=local*,
ignore=lib_*,local*,target,tests

[mypy]
files = src
python_version = 3.6
allow_redefinition = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
no_implicit_optional = True
local_partial_types = True
strict_equality = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unused_ignores = True
warn_unreachable = True

[mypy-asgiref.*]
ignore_missing_imports = True

[mypy-blinker.*]
ignore_missing_imports = True

[mypy-dotenv.*]
ignore_missing_imports = True

[mypy-cryptography.*]
ignore_missing_imports = True
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Setup file for SysDig Secure Connector.

This will create a wheel file with the module name as `sysdig_connector`
"""
from setuptools import setup

PACKAGE_NAME = "secureEvents_connector"
py_typed = ["py.typed"]

setup(
packages={
f"{PACKAGE_NAME}": py_typed,
f"{PACKAGE_NAME}.controller": py_typed,
f"{PACKAGE_NAME}.utils": py_typed,
},
install_requires=[],
setup_requires=["pytest-runner"],
)
29 changes: 29 additions & 0 deletions src/SysDig_connector.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Metadata-Version: 2.1
Name: SysDig-connector
Version: 1.0.0
Summary: Connector to connect to Target system, get events and store it an file locally.
Home-page: UNKNOWN
Author: Sacumen
Author-email: gauri.indani@sacumen.com
Maintainer: Sacumen
Maintainer-email: deepak.baraik@sacumen.com
License: Private
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.6
Description-Content-Type: text/x-rst

UNKNOWN

12 changes: 12 additions & 0 deletions src/SysDig_connector.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
README.md
setup.cfg
setup.py
src/SysDig_connector.egg-info/PKG-INFO
src/SysDig_connector.egg-info/SOURCES.txt
src/SysDig_connector.egg-info/dependency_links.txt
src/SysDig_connector.egg-info/not-zip-safe
src/SysDig_connector.egg-info/top_level.txt
src/secureEvents_connector/controller/client.py
src/secureEvents_connector/controller/data.py
src/secureEvents_connector/utils/__init__.py
src/secureEvents_connector/utils/general.py
1 change: 1 addition & 0 deletions src/SysDig_connector.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/SysDig_connector.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/SysDig_connector.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secureEvents_connector
Loading