Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: made missing errors as internal server error and added depth in scim knex

=e042f9b5e29b
diff --git a/backend/src/lib/knex/scim.ts b/backend/src/lib/knex/scim.ts
index 255d8778b1..0caf8c491d 100644
--- a/backend/src/lib/knex/scim.ts
+++ b/backend/src/lib/knex/scim.ts
@@ -11,8 +11,11 @@ const appendParentToGroupingOperator = (parentPath: string, filter: Filter) => {
const processDynamicQuery = (
rootQuery: Knex.QueryBuilder,
scimRootFilterAst: Filter,
- getAttributeField: (attr: string) => string | null
+ getAttributeField: (attr: string) => string | null,
+ depth = 0
) => {
+ if (depth > 10) return;
+
const stack = [
{
scimFilterAst: scimRootFilterAst,
@@ -76,7 +79,7 @@ const processDynamicQuery = (
case "and": {
scimFilterAst.filters.forEach((el) => {
void query.andWhere((subQueryBuilder) => {
- processDynamicQuery(subQueryBuilder, el, getAttributeField);
+ processDynamicQuery(subQueryBuilder, el, getAttributeField, depth + 1);
});
});
break;
@@ -84,14 +87,14 @@ const processDynamicQuery = (
case "or": {
scimFilterAst.filters.forEach((el) => {
void query.orWhere((subQueryBuilder) => {
- processDynamicQuery(subQueryBuilder, el, getAttributeField);
+ processDynamicQuery(subQueryBuilder, el, getAttributeField, depth + 1);
});
});
break;
}
case "not": {
void query.whereNot((subQueryBuilder) => {
- processDynamicQuery(subQueryBuilder, scimFilterAst.filter, getAttributeField);
+ processDynamicQuery(subQueryBuilder, scimFilterAst.filter, getAttributeField, depth + 1);
});
break;
}
@@ -100,7 +103,8 @@ const processDynamicQuery = (
processDynamicQuery(
subQueryBuilder,
appendParentToGroupingOperator(scimFilterAst.attrPath, scimFilterAst.valFilter),
- getAttributeField
+ getAttributeField,
+ depth + 1
);
});
break;
diff --git a/backend/src/server/plugins/error-handler.ts b/backend/src/server/plugins/error-handler.ts
index 03681b1c89..76bfa9023a 100644
--- a/backend/src/server/plugins/error-handler.ts
+++ b/backend/src/server/plugins/error-handler.ts
@@ -97,7 +97,11 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
message
});
} else {
- void res.send(error);
+ void res.status(HttpStatusCodes.InternalServerError).send({
+ statusCode: HttpStatusCodes.InternalServerError,
+ error: "InternalServerError",
+ message: "Something went wrong"
+ });
}
});
});