Skip to content

[backend] Define a logic for saving structured outputs #3162

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

Open
wants to merge 32 commits into
base: release/current
Choose a base branch
from

Conversation

savacano28
Copy link
Contributor

@savacano28 savacano28 commented May 13, 2025

Proposed changes

  • Add a new attribute to execution traces to save structured results (calculated from existing output parsers).
  • Refact to calculate structured output when an output parser has been defined.
  • Refact the compute of findings to use structured output as input instead of raw output.

Testing Instructions

  1. Create a payload with a output parser
    Exemple PortScan: (TCP|UDP)\s+([\d.[]:]+):(\d+)\s+([\d.[]:]+):(\d+|*)\s+(\S+) {host:$2, port: $3, service: $6}
    image

  2. Execute an inject with this paylaod

  3. Verify in DDBB if there is any trace with a value in the column: structured_message (with the output parser structure)
    image

  4. If you have enabled findings, verify if any find was created

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality
  • For bug fix -> I implemented a test that covers the bug

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@savacano28 savacano28 self-assigned this May 13, 2025
@savacano28 savacano28 added the filigran team use to identify PR from the Filigran team label May 13, 2025
@savacano28 savacano28 changed the title [backend/frontend] Add output parsers as condition of chaining injects [backend/frontend] Define a logic for saving structured outputs May 15, 2025
@savacano28 savacano28 linked an issue May 15, 2025 that may be closed by this pull request
@savacano28 savacano28 force-pushed the issue/2972 branch 4 times, most recently from 64a939c to e792c56 Compare May 21, 2025 09:27
@savacano28 savacano28 marked this pull request as ready for review May 21, 2025 13:05
@savacano28 savacano28 force-pushed the issue/2972 branch 2 times, most recently from 36da149 to e922925 Compare May 22, 2025 09:52
@OpenBAS-Platform OpenBAS-Platform deleted a comment from codecov bot May 22, 2025
Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 54.82234% with 89 lines in your changes missing coverage. Please review.

Project coverage is 42.41%. Comparing base (5ce39fd) to head (a1ce60c).

Files with missing lines Patch % Lines
...n/java/io/openbas/rest/finding/FindingService.java 0.00% 37 Missing ⚠️
...bas/rest/inject/service/StructuredOutputUtils.java 71.55% 22 Missing and 9 partials ⚠️
...as/rest/inject/service/InjectExecutionService.java 47.36% 18 Missing and 2 partials ⚠️
...ain/java/io/openbas/rest/injector/InjectorApi.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##             release/current    #3162      +/-   ##
=====================================================
+ Coverage              42.27%   42.41%   +0.14%     
- Complexity              2484     2505      +21     
=====================================================
  Files                    704      707       +3     
  Lines                  21800    21843      +43     
  Branches                1483     1497      +14     
=====================================================
+ Hits                    9215     9265      +50     
+ Misses                 12077    12064      -13     
- Partials                 508      514       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@savacano28 savacano28 changed the title [backend/frontend] Define a logic for saving structured outputs [backend] Define a logic for saving structured outputs May 23, 2025
@MarineLeM
Copy link
Contributor

Test : ok

@savacano28 savacano28 requested a review from MarineLeM May 23, 2025 09:05
@Dimfacion Dimfacion self-requested a review May 23, 2025 13:33
@Dimfacion
Copy link
Member

To help understand what is done in this PR and improve readability, do you think you could add more comments and/or javadocs ?

@Dimfacion
Copy link
Member

I noticed that when no value is saved in execution_structured_output it's saved as the text 'null' instead of the null value. You can see the difference between value that were saved before the migration and new ones
image

Dimfacion
Dimfacion previously approved these changes May 27, 2025
@Dimfacion Dimfacion dismissed their stale review May 27, 2025 11:44

Still OK with the PR but I'm wondering if we should merge it now or after the next release

@savacano28 savacano28 requested a review from Dimfacion May 27, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define a logic for saving structured outputs
3 participants