Skip to content

osquery: Post the file carving archive event again - #1804

Merged
np5 merged 1 commit into
mainfrom
osquery-file-carving-archive-url
Nov 18, 2026
Merged

np5 merged 1 commit into
mainfrom
osquery-file-carving-archive-url

Conversation

@np5

@np5 np5 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

build_file_carving_session_archive saves the archive of an Osquery file carving session, then posts an osquery_file_carving event with the archive action. It read the archive URL from FileCarvingSession.get_archive_url(), which the Osquery app overhaul (b24befc, 2021) removed. The task raised an AttributeError after it saved the archive, and the event was never posted.

Change

  • FileCarvingSession.get_archive_url() is back. It gives the absolute URL of the console download view, osquery:download_file_carving_session_archive, built with api_base_url(), like the other absolute URLs (MetaMachine.get_url, the Osquery enrollment download URLs). Before the overhaul, it used settings["api"]["tls_hostname"], the deprecated form of the same base URL.
  • The task still passes None, None as the user agent and the IP address: there is no request, so the event has no metadata.request.
  • The task deletes its temporary tar file when it cannot read a block or save the archive. Before, the file stayed on the worker.
  • One entry in the 2026.6 bug fixes. It also says that the sessions archived before the fix get no event: the task returns early when the archive exists, and the archive stays downloadable from the console.

Not changed

  • No guard on a missing api.fqdn. An agent cannot send a carve without this setting: the Osquery flags (tls_hostname in Configuration.get_all_flags) and the enrollment packages read it with no fallback.

Tests

In tests/osquery/test_tasks.py:

  • A session with two blocks, saved out of order. The test checks the archive content, the event payload (action, name, size, URL) and that the serialized metadata has no request. It fails on main with the AttributeError.
  • The same session, with a failing block read and with a failing archive save. The test checks that the temporary file is deleted, that the session has no archive and that no event is posted. The block read case fails without the change.
  • The tests delete the block and archive files that they write to the shared storage.
  • The expected URL is written out by hand, not built with api_base_url(), so the test also checks the route name.

Checks

  • flake8 and ruff on the changed files.
  • The full suite in a dedicated docker compose stack, like CI: OK.

🤖 Generated with Claude Code

@coveralls

coveralls commented Nov 17, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 44405685875

Coverage increased (+0.03%) to 91.643%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 12 of 12 lines across 2 files are fully covered (100%).
  • 1 coverage regression across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
zentral/conf/context_processors.py 1 92.86%

Coverage Stats

Coverage Status
Relevant Lines: 60941
Covered Lines: 55848
Line Coverage: 91.64%
Coverage Strength: 0.92 hits per line

💛 - Coveralls

@np5
np5 force-pushed the osquery-file-carving-archive-url branch 2 times, most recently from e3af6ac to 4760b03 Compare November 18, 2026 21:37
The archive task read the archive URL from FileCarvingSession.get_archive_url,
which the Osquery app overhaul (b24befc) removed. The task raised an
AttributeError after it saved the archive, and the osquery_file_carving event
with the archive action was never posted.

The method is back, with the absolute URL of the console download view, built
with api_base_url() like the other absolute URLs. The task still posts the
event with no user agent and no IP address, so the event has no request.

The sessions archived before the fix get no event: the task returns early
when the archive exists.

The task also deletes its temporary file when it cannot read a block or save
the archive. The tests delete the block and archive files they write to the
shared storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@soysauceconspiracy soysauceconspiracy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@np5
np5 merged commit 6098292 into main Nov 18, 2026
8 checks passed
@np5
np5 deleted the osquery-file-carving-archive-url branch November 18, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants