Skip to content

Commit

Permalink
stream consumption improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-filigran committed Jul 25, 2024
1 parent a600a3c commit 979419e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ Proceed as follows to enable the ingestion of indicators:
| Parameter | Description |
|-----------------|----------------------------------------------------------------------------------------------------------------|
| `Name` | Unique name for the input being configured |
| `Interval` | Time interval of input in seconds. Leave as default (0) to allow continuous execution of the ingestion process. |
| `Interval` | Time interval of input in seconds. Leave as default (0) to allow continuous execution of the ingestion process |
| `Index` | The index that the data will be stored in (default) |
| `Stream Id` | The Live Stream ID of the OpenCTI stream to consume |
| `Import from` | The number of days to go back for the initial data collection (default: 30) (optional) |
| `Import from` | The number of days to go back for the initial data collection (default: 30) (optional) |

4. Once the Input parameters have been correctly configured click "Add".

Expand Down
7 changes: 4 additions & 3 deletions TA-opencti-add-on/bin/input_module_opencti_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ def collect_events(helper, ew):
if state is None:
helper.log_info("No state, going to initialize it")
import_from = helper.get_arg('import_from')
start_date = datetime.utcnow().replace(microsecond=0) - timedelta(days=int(import_from))
start_date_timestamp = int(datetime.timestamp(start_date))
state = {"start_from": str(start_date_timestamp)}
recover_until = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
start_date = datetime.utcnow() - timedelta(days=int(import_from))
start_date_timestamp = int(datetime.timestamp(start_date)) * 1000
state = {"start_from": str(start_date_timestamp)+"-0", "recover_until": recover_until}
helper.log_info(f"Initialized state: {state}")
else:
state = json.loads(state)
Expand Down

0 comments on commit 979419e

Please sign in to comment.