-
Notifications
You must be signed in to change notification settings - Fork 106
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
[frontend] add output in payload form #2790
base: release/current
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/current #2790 +/- ##
=====================================================
+ Coverage 40.59% 40.62% +0.02%
- Complexity 2081 2088 +7
=====================================================
Files 638 640 +2
Lines 19518 19559 +41
Branches 1324 1331 +7
=====================================================
+ Hits 7924 7945 +21
- Misses 11161 11178 +17
- Partials 433 436 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ca4b268
to
af2f7b2
Compare
ded0569
to
7ec815e
Compare
Tested OK :):
|
multiline?: boolean; | ||
rows?: number; | ||
required?: boolean; | ||
style?: CSSProperties; | ||
isCommand?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not super fan to have this specific property in a generic component
@@ -44,6 +46,10 @@ public Payload upsertPayload(PayloadUpsertInput input) { | |||
input.getAttackPatternsExternalIds()))); | |||
existingPayload.setTags(iterableToSet(tagRepository.findAllById(input.getTagIds()))); | |||
existingPayload.setUpdatedAt(Instant.now()); | |||
|
|||
outputParserUtils.removeOrphanOutputParsers( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure to understand why we need to have a specific request here since we have this constraint on the Payload bean
@onetomany(mappedBy = "payload", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JsonProperty("payload_output_parsers")
private Set outputParsers = new HashSet<>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case when we update the list of outputparsers (remove an output parser from a payload) we need to remove the reference parent (payload) from output parser and delete it from the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you need to add orphanRemoval = true I suppose.
This should be handled automatically, not manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you are right, the issue was when I added it, I had a weird behavior in the updated and in the payloadService.generateDuplicatedPayload for the execution of the inject.
@@ -38,6 +38,26 @@ class CreatePayload extends Component { | |||
} | |||
|
|||
onSubmit(data) { | |||
function cleanupObjects(array, idKey, nestedKey, cleanupFn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to do that ?
const [activeTab, setActiveTab] = useState(tabs[0]); | ||
|
||
const handleActiveTabChange = (_: SyntheticEvent, newValue: string) => { | ||
setActiveTab(newValue); | ||
}; | ||
|
||
const regexGroupObject = z.object({ | ||
regex_group_id: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have this ? The ID is generated by the back-end no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we are updating un object, we pass the id.
}); | ||
|
||
const contractOutputElementObject = z.object({ | ||
contract_output_element_id: z.string().optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
contract_output_element_is_finding: z.boolean().optional(), | ||
contract_output_element_name: z.string().min(1, { message: t('Should not be empty') }), | ||
contract_output_element_key: z.string().min(1, { message: t('Should not be empty') }), | ||
contract_output_element_type: z.string().min(1, { message: t('Should not be empty') }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be z.enum(['text', 'number', etc.]) no ?
}); | ||
const outputParserObject = z.object({ | ||
output_parser_id: z.string().optional(), | ||
output_parser_mode: z.string().min(1, { message: t('Should not be empty') }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be an enum here
const outputParserObject = z.object({ | ||
output_parser_id: z.string().optional(), | ||
output_parser_mode: z.string().min(1, { message: t('Should not be empty') }), | ||
output_parser_type: z.string().min(1, { message: t('Should not be empty') }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
output_parser_id: z.string().optional(), | ||
output_parser_mode: z.string().min(1, { message: t('Should not be empty') }), | ||
output_parser_type: z.string().min(1, { message: t('Should not be empty') }), | ||
output_parser_contract_output_elements: z.array(contractOutputElementObject).optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not aligned with the back-end
@NotNull
private Set contractOutputElements = new HashSet<>();
const selectedContractOutputElementType = watch(`${prefixName}.${index}.contract_output_element_type`) as keyof typeof defaultFields | undefined; | ||
const regexGroups: RegexGroup[] = watch(`${prefixName}.${index}.contract_output_element_regex_groups`); | ||
|
||
const outputParserTypeList = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should come from the contract_output_element_type type no ?
const { t } = useFormatter(); | ||
const theme = useTheme(); | ||
const { control, setValue } = useFormContext(); | ||
const outputParserName = 'payload_output_parsers.0.output_parser_contract_output_elements'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the index is 0 here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because for this first implementation we only have one outputParser on the payload with the type = REGEX and the mode = STDOUT
@@ -38,6 +38,26 @@ class CreatePayload extends Component { | |||
} | |||
|
|||
onSubmit(data) { | |||
function cleanupObjects(array, idKey, nestedKey, cleanupFn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…or (#2653) Co-authored-by: Yann <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Proposed changes
Related issues
Further comments