Skip to content

Commit

Permalink
Merge pull request #1009 from Johann-PLW/main
Browse files Browse the repository at this point in the history
Update Splitwise.py for lava output
  • Loading branch information
Johann-PLW authored Jan 8, 2025
2 parents 890a481 + fb50852 commit dda769c
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 347 deletions.
1 change: 1 addition & 0 deletions admin/docs/artifact_info_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ __artifacts_v2__ = {
- `"kml"`: Generates KML (Keyhole Markup Language) output for Google Earth
- `"none"`: Any output generated (For modules only collecting device info)
- `artifact_icon`: The name of the feathericon to display in the left sidebar ot the HTML report. List of available icons on [feathericons.com](https://feathericons.com) website
- `html_columns`: The name of the columns that contain HTML code to render it properly in the HTML report. This key is used to populate the optional argument `html_no_escape` in the report.write_artifact_data_table() function.

This info block provides essential metadata about the artifact and is used by the artifact processor to handle the artifact correctly. The plugin loader will attach this information to the corresponding function, making it accessible via the function's globals.

Expand Down
94 changes: 63 additions & 31 deletions admin/docs/module_updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,47 +128,79 @@ Delete any code related to manual report generation, including:
- Generating timeline or KML files
- Any print or logging statements about no data being available: `print()` or `logdev()`

### 6. Add chat parameters if the artifact should support a threaded type view
### 6. Use a distinct data_list for HTML report

Some artifacts contain data with HTML elements that can be rendered in the HTML report but are not of particular interest for other types of output.
For that particular case, you must generate a distinct data_list_html and return a tuple containing the normal data_list in first position and data_list_html in second position.

Example from splitwiseNotifications artifact:
```python
for record in db_records:
created_ts = convert_unix_ts_to_utc(record[0])
data_list_html.append((created_ts, record[1], record[2], record[3]))
if '<strong>' and '</strong>' in record[1]:
remove_html = record[1].replace('<strong>', '').replace('</strong>', '')
data_list.append((created_ts, remove_html, record[2], record[3]))

return data_headers, (data_list, data_list_html), source_path
```

You also have to indicate in `__artifact_v2__` block which columns contain HTML code to render it properly in the HTML report.

Example from splitwiseNotifications artifact:
```python
__artifacts_v2__ = {
"splitwiseNotifications": {
# Usual key information about the artifact
"html_columns": ['Notification']
}
}
```

### 7. Add chat parameters if the artifact should support a threaded type view

Instructions:

The `chatParams` key will contain a dictionary of items to assist LAVA in determining which columns should be used to group messages into threads and which columns should be used to render the elements of the chat message bubble. Whenever a column name is specified it should match the column header as defined in the `data_headers` of the artifact.

__artifacts_v2__ = {
"get_artifactname": {
# Other parameters as shown above,
"chatParams": {
"threadDiscriminatorColumn": Column that determines which thread messages belong to. This must be unique for each thread
"threadLabelColumn": Optional column name providing a friendly name for the thread
"textColumn": Column name containing the text message
"directionColumn": Column name to determine if the message was sent/received
"directionSentValue": Any Value that if present in the directionColumn specified above indicates the message was sent (ie: 1, True, "SENT"), any other value treated as received.
"timeColumn": Column name containing the DateTime for the message (presumably the sent time),
"senderColumn": Column name containing the senders name/identifier,
"mediaColumn": Optional column containing an attachment (Further development required on this),
"sentMessageLabelColumn": Optional column name containing the local users name/identifier (used for a case where the data only contains the remote users information and the senders information is located in a different column (ie an Account ID),
"sentMessageStaticLabel": Optional string that will provide a static sender name/identifier for artifacts where this is unknown (ie "Local User")
}
```python
__artifacts_v2__ = {
"get_artifactname": {
# Other parameters as shown above,
"chatParams": {
"threadDiscriminatorColumn": Column that determines which thread messages belong to. This must be unique for each thread
"threadLabelColumn": Optional column name providing a friendly name for the thread
"textColumn": Column name containing the text message
"directionColumn": Column name to determine if the message was sent/received
"directionSentValue": Any Value that if present in the directionColumn specified above indicates the message was sent (ie: 1, True, "SENT"), any other value treated as received.
"timeColumn": Column name containing the DateTime for the message (presumably the sent time),
"senderColumn": Column name containing the senders name/identifier,
"mediaColumn": Optional column containing an attachment (Further development required on this),
"sentMessageLabelColumn": Optional column name containing the local users name/identifier (used for a case where the data only contains the remote users information and the senders information is located in a different column (ie an Account ID),
"sentMessageStaticLabel": Optional string that will provide a static sender name/identifier for artifacts where this is unknown (ie "Local User")
}
```

Example (From googleChat.py artifact):

__artifacts_v2__ = {
"get_googleChat": { # This should match the function name exactly
"name": "Google Chat",
# Other parameters as shown above,
"chatParams": {
"threadDiscriminatorColumn": "Conversation Name",
"textColumn": "Message",
"directionColumn": "Is Sent",
"directionSentValue": 1,
"timeColumn": "Timestamp",
"senderColumn": "Message Author",
"mediaColumn": "Media"
}
```python
__artifacts_v2__ = {
"get_googleChat": { # This should match the function name exactly
"name": "Google Chat",
# Other parameters as shown above,
"chatParams": {
"threadDiscriminatorColumn": "Conversation Name",
"textColumn": "Message",
"directionColumn": "Is Sent",
"directionSentValue": 1,
"timeColumn": "Timestamp",
"senderColumn": "Message Author",
"mediaColumn": "Media"
}
}
}
```

### 7. Update Device Information Collection
### 8. Update Device Information Collection

The `logdevinfo()` function is being deprecated in favor of the new `device_info()` function. This new function provides better organization and structure for device-related information. Not every module uses these functions, so this section is only applicable to modules that do.

Expand Down
Loading

0 comments on commit dda769c

Please sign in to comment.