Conversation
lib/routes/bins/update.js
Outdated
| ); | ||
| // TODO: add switch in client | ||
| // TODO: add it to create | ||
| mock._dynamicMockInBody = true; |
There was a problem hiding this comment.
nice job so far, how do you propose to determine this value in the client?
Why do we need to know this, is it an early optimisation? does the library waste resource if given a string without tags? If not it could be avoided, and we can just let the library optimise itself.
36d8ba5 to
6b9eabb
Compare
e320c6c to
2770a96
Compare
* security patches * resolves INS-2135, INS-1977
| const ajv = new Ajv({ | ||
| allErrors: true, // Reports all errors found | ||
| strict: false, // Used for setting the custom property (`violationMessage`) in mockSchema. | ||
| useDefaults: true, // This will fill in default values within the schema. Resolves backward compatibility issues when changing schemas. | ||
| }); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.ajv.security.audit.ajv-allerrors-true.ajv-allerrors-true Warning
…uire for better dx. Refine log output when starting server.
f2aa4e4 to
de78932
Compare
Rename image name Remove self-hosted image
d67da70 to
be72b39
Compare
bcab10a to
266aa24
Compare
266aa24 to
f310f12
Compare
| minimum: -1, | ||
| default: -1, | ||
| errorMessage: | ||
| "The 'headersSize' property must be >= 0 and of type integer.", | ||
| }, | ||
| bodySize: { | ||
| type: "integer", | ||
| minimum: -1, | ||
| default: -1, | ||
| errorMessage: | ||
| "The 'bodySize' property must be >= 0 and of type integer.", |
There was a problem hiding this comment.
The 'headersSize' rule allows -1, but its error message says values must be >= 0; this contradicts the actual validation behavior.
Show fix
| minimum: -1, | |
| default: -1, | |
| errorMessage: | |
| "The 'headersSize' property must be >= 0 and of type integer.", | |
| }, | |
| bodySize: { | |
| type: "integer", | |
| minimum: -1, | |
| default: -1, | |
| errorMessage: | |
| "The 'bodySize' property must be >= 0 and of type integer.", | |
| minimum: -1, | |
| "The 'headersSize' property must be >= -1 and of type integer.", | |
| }, | |
| bodySize: { | |
| type: "integer", | |
| minimum: -1, | |
| default: -1, | |
| errorMessage: | |
| "The 'bodySize' property must be >= -1 and of type integer.", |
Details
✨ AI Reasoning
The validation rule for one numeric size field allows -1, but the error text claims values must be greater than or equal to 0. This creates contradictory behavior: accepted values conflict with the documented constraint, producing misleading validation semantics.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
| "The 'headersSize' property must be >= 0 and of type integer.", | ||
| }, | ||
| bodySize: { | ||
| type: "integer", | ||
| minimum: -1, | ||
| default: -1, | ||
| errorMessage: | ||
| "The 'bodySize' property must be >= 0 and of type integer.", |
There was a problem hiding this comment.
The 'bodySize' rule allows -1, but its error message says values must be >= 0; validation logic and message are inconsistent.
Show fix
| "The 'headersSize' property must be >= 0 and of type integer.", | |
| }, | |
| bodySize: { | |
| type: "integer", | |
| minimum: -1, | |
| default: -1, | |
| errorMessage: | |
| "The 'bodySize' property must be >= 0 and of type integer.", | |
| "The 'headersSize' property must be >= -1 and of type integer.", | |
| }, | |
| bodySize: { | |
| type: "integer", | |
| minimum: -1, | |
| default: -1, | |
| errorMessage: | |
| "The 'bodySize' property must be >= -1 and of type integer.", |
Details
✨ AI Reasoning
Another numeric size field has the same contradiction between allowed range and stated requirement. The validator accepts -1, yet the message describes a stricter lower bound. This mismatch can lead to incorrect assumptions about what inputs are valid.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Since the master branch contains code that has not yet been deployed to production, it is recommended to review the changes by comparing feat/dynamic-mock against the v2.0.12 tag rather than against master.
The cloud mock currently uses an image built from the v2.0.12 codebase. This PR merges the latest updates from the master and self-hosted branches and resolves all conflicts.
Once this PR is merged into master, this repository will only maintain the master branch going forward. The self-hosted branch and its corresponding Docker image will be removed. Both the cloud mock and self-hosted mock will share a single image, published at https://github.com/Kong/insomnia-mockbin/pkgs/container/insomnia-mockbin.
Dynamic Mock INS-478 INS-1977
New Features
Dynamic Mock with Liquid templating
compoundIdis now composed of{method}{uuid}{path}, allowing different bins to be matched per HTTP method and sub-path.req.headers,req.queryParams,req.pathSegments,req.body).@faker-js/fakerto generate random dynamic values in templates (e.g.{{ faker.randomEmail }},{{ faker.guid }}).PUT /bin/upsert/:uuid*endpoint to create or update a bin.Backward compatibility
compoundId, the server automatically retries with the legacycompoundId(without method prefix), ensuring existing bins created before this change continue to work.Cloud mock mode (
MOCKBIN_IS_CLOUD_MOCK)/ip,/echo,/har,/request,/headers, etc.) and bin management UI routes (/bin/create,/bin/view,/bin/sample) are disabled. Only the core bin run/log/upsert/delete endpoints are exposed.MOCKBIN_CLOUD_RESTRICTED_HEADERS(comma-separated list).Security & Bug Fixes
X-Powered-Byheader from responses to avoid exposing server technology.next(e)to prevent service crashes.Infrastructure
node:22-alpineto address high severity vulnerabilities innode:22-bullseye-slim.