Skip to content

Commit ce85f59

Browse files
khode-mxclaude
andcommitted
fix: cap HTTP spec fetch at 10 MB; clarify sanitizeModuleName vs sanitizeIdent
- fetchSpecBytes: wrap resp.Body in io.LimitReader(10 MiB) before ReadAll to prevent memory exhaustion from oversized or malicious spec URLs - sanitizeModuleName: add comment explaining intentional PascalCase vs snake_case difference relative to openapi.sanitizeIdent (service names vs operation names follow different Mendix naming conventions) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 362e5ca commit ce85f59

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

mdl/executor/cmd_rest_clients.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ func convertOpenAPIToModel(parsed *openapi.ConsumedRestService, containerID mode
770770
return svc
771771
}
772772

773-
// sanitizeModuleName converts a spec title to a valid MDL identifier suitable as a service name.
773+
// sanitizeModuleName converts a spec title to a PascalCase MDL identifier suitable as a service/module name.
774+
// This is intentionally different from openapi.sanitizeIdent (which produces snake_case for operation names):
775+
// service names follow Mendix PascalCase convention while operation names follow snake_case.
774776
func sanitizeModuleName(title string) string {
775777
// Replace spaces and non-alphanumeric with nothing (PascalCase-ish)
776778
var b strings.Builder
@@ -823,7 +825,7 @@ func fetchSpecBytes(specPath, baseDir string) ([]byte, string, error) {
823825
if resp.StatusCode != http.StatusOK {
824826
return nil, normalised, fmt.Errorf("spec fetch returned HTTP %d from %s", resp.StatusCode, normalised)
825827
}
826-
data, err := io.ReadAll(resp.Body)
828+
data, err := io.ReadAll(io.LimitReader(resp.Body, 10<<20)) // 10 MB cap
827829
if err != nil {
828830
return nil, normalised, fmt.Errorf("read spec response: %w", err)
829831
}

0 commit comments

Comments
 (0)