Conversation
e2a5527 to
5aaf473
Compare
873baae to
c18a065
Compare
c18a065 to
d8286e4
Compare
d8286e4 to
d9e2ca0
Compare
d9e2ca0 to
7fec22c
Compare
7fec22c to
75f1b9c
Compare
75f1b9c to
a93225e
Compare
a93225e to
f9f09f4
Compare
f9f09f4 to
0dce511
Compare
0dce511 to
b740693
Compare
b740693 to
54cb231
Compare
54cb231 to
7592bac
Compare
| ); | ||
| } | ||
|
|
||
| const instance = |
There was a problem hiding this comment.
isn't one service enough
getVcpmAggregateBySubgraph -> it should return all VCPM related information. Why are defining lot of methods when it is not used anywhere
There was a problem hiding this comment.
VCPM is a subgraph proeprty. So subgraphQueryService should be used for adding get APIs
| fileSystemId: number, | ||
| ): Promise<VcpmParameterPayloadReadModel[]>; | ||
|
|
||
| getVcpmParameterDefinitions( |
There was a problem hiding this comment.
This should go in subgraph properties definition queryService
add lld for vcpm data Signed-off-by: Robin Gupta <robigupt@qti.qualcomm.com>
add end-to-end support for retrieving for vcpm data Signed-off-by: Robin Gupta <robigupt@qti.qualcomm.com>
7592bac to
aab53ee
Compare
| fileSystemId, | ||
| query.paramSystemIds.length > 0 ? query.paramSystemIds : undefined, | ||
| ); | ||
|
|
||
| const paramSystemIds = payloads.map(p => p.vcpmParameterSystemId); | ||
| const paramDefs = | ||
| await this.queryServices.vcpmQueryService.getVcpmParameterDefinitions( | ||
| paramSystemIds, | ||
| ); | ||
| const defMap = new Map(paramDefs.map(d => [d.systemId, d])); | ||
|
|
There was a problem hiding this comment.
[FUNCTIONALITY][MEDIUM] Missing null-safety validation in parameter definition lookup
In GetVcpmCalDataHandler.handle(), the code retrieves parameter definitions and creates a map, but when looking up definitions for each payload, it throws an error if a definition is missing. However, there's a potential race condition or data integrity issue: if paramDefs returns fewer definitions than requested (e.g., due to concurrent deletion or database inconsistency), the error thrown at line 73 might not provide sufficient context about which specific parameter IDs are missing.
The current implementation assumes all parameter system IDs in payloads will have corresponding definitions returned, but this isn't validated before the map lookup loop.
Impact: Could result in unclear error messages during debugging, making it harder to diagnose data integrity issues.
Fixed Code Snippet
const paramSystemIds = payloads.map(p => p.vcpmParameterSystemId);
const paramDefs =
await this.queryServices.vcpmQueryService.getVcpmParameterDefinitions(
paramSystemIds,
);
const defMap = new Map(paramDefs.map(d => [d.systemId, d]));
// Validate all required definitions were retrieved
const missingDefIds = paramSystemIds.filter(id => !defMap.has(id));
if (missingDefIds.length > 0) {
throw new ParameterDefinitionMissingError(
`Missing parameter definitions for IDs: ${missingDefIds.join(', ')}`
);
}
const parameters = payloads.map(p => {
const def = defMap.get(p.vcpmParameterSystemId)!; // Now safe to use non-null assertion| payloadActions.filter(a => a.operation !== CHANGE_OPERATION.Create), | ||
| ) | ||
| .map(r => r.effective as unknown as VcpmParameterPayloadBase); | ||
|
|
||
| const baseIds = new Set(baseRows.map(r => r.systemId)); | ||
| const deletedIds = new Set( | ||
| payloadActions | ||
| .filter(a => a.operation === CHANGE_OPERATION.Delete) | ||
| .map(a => a.targetSystemId), | ||
| ); | ||
|
|
There was a problem hiding this comment.
[PERFORMANCE][HIGH] Inefficient filtering in fetchParameterPayloadsByInstance creates unnecessary overhead
In VcpmOverlayFetcher.fetchParameterPayloadsByInstance(), the code builds a validCkvIds set by iterating through ALL edit actions to find CKV creates (lines 297-307). This is inefficient because:
- It iterates through the entire
actionsarray (which includes actions for all entity types) when we only needVcpmCkvcreates - The
actionsarray was already filtered once forpayloadActionsat line 274, but then we iterate through the unfilteredactionsagain - For large sessions with many edit actions, this creates O(n) overhead where n is the total number of actions
Impact: Performance degradation with large edit sessions, especially when there are many non-VCPM-related actions.
Fixed Code Snippet
const baseIds = new Set(baseRows.map(r => r.systemId));
const deletedIds = new Set(
payloadActions
.filter(a => a.operation === CHANGE_OPERATION.Delete)
.map(a => a.targetSystemId),
);
// Build validCkvIds efficiently by filtering CKV actions once
const validCkvIds = new Set(baseRows.map(r => r.vcpmCkvSystemId));
const ckvActions = actions.filter(
a => a.targetTable === ENTITY_NAMES.VcpmCkv &&
a.operation === CHANGE_OPERATION.Create
);
for (const a of ckvActions) {
const p = a.newValue as {vcpmInstanceSystemId?: number};
if (p.vcpmInstanceSystemId === vcpmInstanceSystemId) {
validCkvIds.add(a.targetSystemId);
}
}| await this.keyValueDefQueryService.getKeyValueSummaryForGivenValues( | ||
| allValueDefIds, | ||
| fileSystemId, | ||
| ); | ||
| if (pairsResult.kind === RESULT_KIND.Fail) { | ||
| const ckvIds = rows.map(r => r.systemId).join(', '); | ||
| throw new Error( | ||
| `Failed to resolve key-value pairs for CKVs [${ckvIds}] (fileSystemId: ${fileSystemId}, valueDefIds: [${allValueDefIds.join(', ')}]): ${pairsResult.issues.map((e: Issue) => e.message).join(', ')}`, | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
[SECURITY][MEDIUM] Error message exposes internal system details
In DbVcpmQueryService.toCkvReadModels(), the error message at line 143-145 exposes detailed internal system information including CKV IDs, file system IDs, and value definition IDs. This could potentially aid attackers in understanding the system's internal structure.
While this is in a private method and the error is thrown (not logged to external systems), the error message could still be exposed through API responses or logs that might be accessible to unauthorized parties.
Impact: Information disclosure that could aid in reconnaissance for potential attacks.
Fixed Code Snippet
if (pairsResult.kind === RESULT_KIND.Fail) {
throw new Error(
`Failed to resolve key-value pairs for CKVs. Please contact system administrator.`,
);
}Alternatively, if detailed logging is needed for debugging, log the details separately at a debug level while throwing a generic error:
if (pairsResult.kind === RESULT_KIND.Fail) {
const ckvIds = rows.map(r => r.systemId).join(', ');
// Log detailed info for debugging (ensure this goes to secure logs only)
console.debug(
`CKV resolution failed: CKVs=[${ckvIds}], fileSystemId=${fileSystemId}, valueDefIds=[${allValueDefIds.join(', ')}]`
);
throw new Error(
`Failed to resolve calibration key-value pairs. Reference ID: ${fileSystemId}`,
);
}added document for updated query service and fetcher design Signed-off-by: Robin Gupta <robigupt@qti.qualcomm.com>
added updated lld for vcpm data Signed-off-by: Robin Gupta <robigupt@qti.qualcomm.com>
|
feat(data) doesnt make sense. Use feat or feat(api), feat(core) etc. |
add lld for vcpm data