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

[backend] crop effective confidence level in [0-100] #5787

Merged
merged 5 commits into from
Feb 5, 2024

Conversation

labo-flg
Copy link
Member

@labo-flg labo-flg commented Feb 1, 2024

Closes #5759

Proposed changes

  • user_effective_level is cropped between [0-100] on computation, that's all
  • no cropping when adding/editing the confidence values of users and groups. Thus we cannot trust them for now (this might be addressed in Enforce input validation against schema for patching object attributes #5696 as part of a new validation against schema, including such numerical constraints)
  • adding confidence information to the internal user in context ; for use internnaly
  • built-in users have a confidence level now (all to 100 so they can do their job correctly).
  • updated test base to improve coverage

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

Further comments

This PR replaces #5768

import type { AuthUser } from '../types/user';
import { cropNumber } from './math';

export const computeUserEffectiveConfidenceLevel = (user: AuthUser) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this function as an utility and added unit tests

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (0c34913) 64.81% compared to head (e335973) 65.57%.
Report is 8 commits behind head on master.

Files Patch % Lines
...encti-platform/opencti-graphql/src/types/user.d.ts 0.00% 3 Missing ⚠️
...ncti-platform/opencti-graphql/src/types/group.d.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5787      +/-   ##
==========================================
+ Coverage   64.81%   65.57%   +0.75%     
==========================================
  Files         521      523       +2     
  Lines       61347    61438      +91     
  Branches     4899     5568     +669     
==========================================
+ Hits        39762    40285     +523     
+ Misses      21585    21153     -432     

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

@labo-flg labo-flg force-pushed the issue/5759-crop-confidence branch 2 times, most recently from b46ab37 to e38bdae Compare February 2, 2024 16:35
@SarahBocognano
Copy link
Member

Tested ✅ Works fine !

@labo-flg labo-flg merged commit 151729c into master Feb 5, 2024
8 checks passed
@labo-flg labo-flg deleted the issue/5759-crop-confidence branch February 5, 2024 13:44
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.

Make sure confidence level is always between 0 and 100
2 participants