Repository navigation
feat: align boat:lint with RESTful API in Backbase v3 and fix security alerts - #1318
Conversation
On OpenAPI 3.1 the parser can return example values as plain Java maps instead of JsonNode, so checkResponseExampleFulfill crashed the whole lint with a ClassCastException. Example values are now converted with ObjectMapper.valueToTree. Schema types are read through the new SchemaUtil.typeNames, which looks at both type (3.0) and types (3.1), so nested objects and arrays are checked on 3.1 documents instead of being reported as missing. Co-authored-by: Cursor <[email protected]>
boat:lint gets a previewRules parameter. Violations of preview rules are logged with a "(preview)" marker and labelled in the HTML report, but never fail the build, even with failOnWarning. A rule is promoted by removing it from the list. The default previewRules are B004 and M010: - B004 now validates info.x-api-dashboard-tags, when present, against the product and informative tags. Top-level tags are no longer required or restricted. - M010 is no longer ignored by default. Its CaseChecker config follows the RESTful API v3 guideline: camelCase path parameters, _metadata, SCREAMING_SNAKE_CASE enum values and the Service SDK headers. Co-authored-by: Cursor <[email protected]>
Add the rules B016 to B024 for the "RESTful API in Backbase v3" guideline: no 405, 408, 422 or 5xx responses, no verbs in paths, path version matching info.version, plain application/json, list response shape, pagination parameters, date and time formats, money and currency, and the Service SDK error body. All are SHOULD and in the default previewRules, so they are reported but do not fail the build. Violations point at the path, operation, response or property they come from, so OpenAPI 3.0 and 3.1 documents report the same locations. Co-authored-by: Cursor <[email protected]>
…ts trail Co-authored-by: Cursor <[email protected]>
Replace commons-lang 2.6 (GHSA-j288-q9x7-2f5v) with commons-text in boat-scaffold and drop the unused dependency from boat-maven-plugin. Bump Spring Boot to 3.5.16 and spring-core to 6.2.19 in the plugin IT example (GHSA-jmp9-x22r-554x, GHSA-659m-px2c-25wj). Co-authored-by: Cursor <[email protected]>
The boat-spring templates generated projects on Spring Boot 3.3.13, which brings the vulnerable spring-core 6.1. They now use Spring Boot 3.5.16 with the matching Spring Cloud 2025.0.3 train and springdoc 2.8.17, since older springdoc releases fail on Spring Framework 6.2. The boat-java restclient templates use spring-web 6.2.19. Co-authored-by: Cursor <[email protected]>
Spring Boot 4.0.1 brings spring-core 7.0.2, which is affected by GHSA-659m-px2c-25wj. The Spring Boot 4 templates now use Spring Boot 4.0.9 with Spring Cloud 2025.1.4 and springdoc 3.0.3, the springdoc line for Spring Boot 4. The spring-cloud template no longer pins spring-security-oauth2-client 6.1.1, so Spring Boot manages it with the rest of Spring Security 7. Co-authored-by: Cursor <[email protected]>
… specs Replace the CloudEvents AsyncAPI test specs with a pet adoption example that covers the same features: JSON Schema 2020-12 Multi Format Schema Objects, const, if/then, shared schemas in a sibling directory, untagged receive and send operations, and channel x-producers/x-consumers. Co-authored-by: Cursor <[email protected]>
| return Schema<Any>().apply { | ||
| properties = members.mapNotNull { it.properties }.fold(LinkedHashMap()) { merged, properties -> | ||
| merged.apply { putAll(properties) } | ||
| } |
There was a problem hiding this comment.
resolve() merges allOf members into a new Schema but copies only properties, required, types and items. format, pattern, enum, minimum, maximum and default are dropped. A property like allOf: [{$ref: DateTime}] (the usual 3.0 way to add a description to a $ref) then loses its format, so B022 reports a false "should have format date-time". B023 (pattern/enum) and B021 (maximum/default) have the same problem.
|
|
||
| fun visit(schema: Schema<*>?, pointer: JsonPointer) { | ||
| if (schema == null || !visited.add(schema)) { | ||
| return |
There was a problem hiding this comment.
Perf nit: namedProperties() walks the whole document and is recomputed independently by B022 and B023. Caching it in the Context (or sharing it between rules) avoids two full traversals plus allOf merging per lint on large specs.
Resolve README 0.19.2 release notes conflict by keeping the bundle/null-default fixes from main and the RESTful API v3 lint rules from this branch. Co-authored-by: Cursor <[email protected]>
|



Summary
Aligns
boat:lintwith the RESTful API in Backbase v3 guideline. It fixes a crash on OpenAPI 3.1 specs, resolves the rules that contradicted the guideline, and adds rules for its core requirements.The new checks are
SHOULDand start as preview rules. Their violations are reported, marked(preview)in the log and labelled in the HTML report, but never fail the build, even withfailOnWarning. A rule is promoted to blocking by removing it from the newpreviewRulesparameter.Changes
Fix
B014on OpenAPI 3.1. The parser can pass example values as plain Java maps, and the rule's cast toJsonNodethrew aClassCastException. The rule also readschema.type, which is null on 3.1 because the type is intypes. The newSchemaUtilhandles both.previewRulesparameter onboat:lint. The default isB004, B016–B024, M010. Supporting changes:BoatLinter(ignoreRules, previewRules).BoatLintReport.hasBlockingViolations(), used byLintMojoto decide whether to fail.BoatViolation.displayString().Rules that contradicted the guideline:
B004checks the optionalinfo.x-api-dashboard-tagsinstead of the top-leveltags, which the guideline uses for grouping operations.M010casing follows the guideline:_linksand_metadata) and path parameters;X-CXT-RequestUUIDandX-B3-*headers;M010is no longer in the defaultignoreRules; it is a preview rule instead.B016flags405,408,422and5xxresponses.New rules, all
SHOULD:B017webhooksB018/v2/) matches the major version ofinfo.versionB019application/jsonwithout parameters such ascharsetB020itemsarray, top-level lists do not return404B021size(integer, default 20, max 100 forclient-api, 1000 otherwise) andpage(minimum 0) orcursorB022date-time,dateortimeB023number; currencies are strings with pattern^[A-Z]{3}$and noenumB0244xxapplication/jsonresponses use the Service SDK error body (stringmessage, optionalkeyanderrors)Violation pointers for the new rules. Pointers are built from the path, method, status, media type or property. On 3.1 the parser can share one model object between identical parts of a document, so Zally's object lookup would point at the wrong operation.
Docs. Added 0.19.2 release notes in
README.mdand documentedpreviewRulesin theboat:lintsection ofboat-maven-plugin/README.md.Also included: the CloudEvents AsyncAPI test specs in
boat-trail-resourcesare replaced with a generic pet adoption example that covers the same features.Impact on consumers
M010now runs by default, so casing violations appear. They are preview, so they don't block the build.ignoreRulesorpreviewRules, that list replaces the default one.Testing
BoatLinterTestslints two guideline fixtures:follows-guideline.yamlhas no guideline violations.violates-guideline.yamltriggers every preview rule, with identical violations and pointers on 3.0.3 and 3.1.0.LintMojoTests: preview-only violations don't fail withfailOnWarning, and do fail whenpreviewRulesis empty.BoatLintTests: 2 passedLintMojoTests: 11 passedKnown limitations
allOfmembers of component schemas when it resolves the document.B022/B023violations on such properties point at the composed schema instead of theallOfmember.B014still finds pointers by object lookup, so on 3.1 some of its violations can point at another operation. This PR does not change that.Security fixes
This PR also fixes the four open Dependabot alerts on
main, and updates the Spring generator templates so generated projects no longer get the vulnerable Spring Framework versions either. These changes were first opened as #1319.Changes
commons-lang 2.6 (GHSA-j288-q9x7-2f5v, alerts Release 0.2.1 #31 and Feature/return of the diff #30). commons-lang 2.x is end of life and has no fixed version.
boat-scaffoldused it for one call: theescapeJavascriptMustache lambda inBoatExample, which theboat-angularmocks template uses. It now usesStringEscapeUtils.ESCAPE_ECMASCRIPTfrom commons-text 1.14.0, the version the plugin already resolves. The commons-lang3 equivalent is deprecated in favour of commons-text. The escaped output is the same as commons-lang 2.6 for quotes, backslashes,/, control characters and non-ASCII characters.org.apache.commons.lang.UnhandledException; they now use lang3'sUncheckedException.boat-maven-plugindeclared commons-lang without using it, so the dependency is removed.spring-core 6.1.21 (GHSA-jmp9-x22r-554x, GHSA-659m-px2c-25wj, alerts Master #33 and Release 0.2.4 #38). In the plugin integration-test example (
boat-maven-plugin/src/it/example/pom.xml), Spring Boot goes from 3.3.13 to 3.5.16 and spring-core from 6.1.21 to 6.2.19.Generator templates. The templates were unchanged copies of upstream openapi-generator 7.20 and generated projects on vulnerable versions: Spring Boot 3.3.13 brings spring-core 6.1.21, and Spring Boot 4.0.1 brings spring-core 7.0.2, which is affected by GHSA-659m-px2c-25wj (fixed in 7.0.8).
boat-springspring-boot/pom-sb3.mustacheboat-springspring-cloud/pom-sb3.mustacheboat-springspring-http-interface/pom.mustacheboat-springspring-boot/pom-sb4.mustacheboat-springspring-cloud/pom-sb4.mustachespring-security-oauth2-client6.1.1boat-springspring-http-interface/pom-sb4.mustacheboat-javarestclientpom.mustacheandbuild.gradle.mustacheThe companion versions follow each Boot line:
spring-cloudtemplate pinned the Spring Security 6.1 oauth2 client next to Boot 4's Spring Security 7. It now leaves the version to Spring Boot, as the Boot 3 template already did.Testing
mvn dependency:treeshows nocommons-lang:commons-langin any module.BoatAngularTemplatesTests, which generates mocks.mvn -pl boat-maven-plugin -am verify -Dgpg.skippasses. That covers all plugin invoker integration tests, including theexampleproject, which compiles and tests generated Spring code against Boot 3.5.16.boat-scaffoldinvoker tests pass. They build the 8 generated Boot 3spring-bootprojects against Boot 3.5.16 and springdoc 2.8.17.mvn package:spring-cloud, Boot 3spring-http-interface, Boot 4spring-cloudand Boot 4spring-http-interfacebuild. The Boot 4spring-cloudproject resolves spring-core 7.0.10 and Spring Security 7.0.8 throughout.restclientand Boot 4spring-bootneeded workarounds for the existing bugs below, and then build.spring-bootapp starts on Boot 3.5.16 and serves/v3/api-docs.spring-bootapp starts on Boot 4.0.9 and serves/v3/api-docsand Swagger UI through springdoc 3.0.3.Existing bugs found, not fixed here
All of these happen with the old versions too.
boat-javarestclientdoesn't generateServerConfigurationandServerVariable, so the generatedApiClientdoesn't compile. For the manual build, I copied the two classes from the upstreamjavagenerator.spring-boot(pom-sb4.mustache) declaresspring-boot-starter-restclienttwice, at compile and test scope. Maven 3.10 rejects the generated pom; older Maven only warns. The generator also doesn't writeApiUtil, which the generated API interfaces use. For the manual build, I removed the duplicate and copiedApiUtilfrom the upstreamspringgenerator.boat-springspring-http-interfacewithuseSpringBoot3=truefails because the library has nopom-sb3.mustache.Not changed
pom.mustacheinspring-bootandspring-cloud) stay on Boot 2.7.15 and Spring Framework 5.3. Spring Framework 5.3 has no open-source fix for these advisories.boat-maven-plugin/src/it/example/boat-generate/asyncapi/pom.xml) still imports the Boot 3.3.13 and Spring Cloud 2023.0.5 BOMs. It resolves spring-core 6.2.19 through the parent pin.