Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The results of uploading CSV files between timesketch_importer CLI and GUI are different #3015

Open
Camel0101 opened this issue Jan 10, 2024 · 1 comment
Labels

Comments

@Camel0101
Copy link

Describe the bug
I have a CSV file. When I import it via the GUI, only the non-empty events are displayed:
pasted_image_20240108202123
However, when I import the same CSV file using the timesketch_importer CLI with this command:

sudo timesketch_importer sample_test.csv --timeline_name "TIMESKETCH_IMPORTER_CSV" --sketch_name "TEST" 

all events, including the empty ones, are shown:
pasted_image_20240108202212

Do you know why there is a difference between the two, and is it possible to achieve the same output as the GUI (excluding empty keys) with the timesketch_importer CLI ?

Desktop:

  • OS: Ubuntu 22.04
  • Browser: Firefox
@Camel0101 Camel0101 added the Bug label Jan 10, 2024
@cichyx96
Copy link

cichyx96 commented Mar 2, 2024

Looks like when uploading via GUI it goes through Celery task which uses pandas to read CSV and it drops all NAN values.

for _, row in chunk.iterrows():
_scrub_special_tags(row)
# Remove all NAN values from the pandas.Series.
row.dropna(inplace=True)
# Make sure we always have a timestamp
if not "timestamp" in row:
row["timestamp"] = int(
pandas.Timestamp(row["datetime"]).value / 1000
)
yield row.to_dict()

CLI importer only reads flie and uploads it as it is.

with import_client.ImportStreamer() as streamer:
click.echo("Uploading to server .. ", nl=False)
streamer.set_sketch(sketch)
streamer.set_timeline_name(name)
streamer.set_provider("Timesketch CLI client")
# TODO: Consider using the whole command as upload context instead
# of the file path.
streamer.set_upload_context(file_path)
streamer.add_file(file_path)
timeline = streamer.timeline
if not timeline:
click.echo("Error creating timeline, please try again.")
sys.exit(1)
click.echo("Done")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants