Skip to content

Require compile-time constants in JspBase.unsafe() - #1095

Merged
labkey-adam merged 3 commits into
developfrom
fb_unsafe
Nov 21, 2026
Merged

labkey-adam merged 3 commits into
developfrom
fb_unsafe

Conversation

@labkey-adam

@labkey-adam labkey-adam commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

This PR makes JspBase.unsafe() accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new @CompileTimeConstant annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with -PerrorProne.

Related Pull Requests

Changes

  • The necropsy report, necropsy collection list, and death notification encode database values, including multiline notes, instead of passing them to unsafe(), keeping their fixed "not specified" markup as trusted constants
  • The pathology case list and water calendar write their JSON data to the page as JSON values

Not compiled locally because this module isn't in my build; checked with IntelliJ inspections.

Encode necropsy, death notification, and pathology values that WNPRC JSPs wrote without encoding.
labkey-adam added a commit to LabKey/targetedms that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/wnprc-modules#1095

## Changes
- The download menu's tracking check works with the analytics tracking
script now being returned as HTML
- The figures of merit page and the spectrum viewer write their CV limit
and chart selector as JavaScript values instead of passing strings to
`unsafe()`

Not compiled locally because this module isn't in my build; checked with
IntelliJ inspections.
@labkey-adam
labkey-adam merged commit 77e0bc2 into develop Nov 21, 2026
5 checks passed
labkey-adam added a commit to LabKey/platform that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- `JspBase.unsafe()` requires a compile-time constant, and its
`CharSequence` overload is removed
- JSPs that built markup from strings now use `HtmlString`, `h()`, link
and button builders, or JavaScript-safe encoding (`q()`, JSON) inside
script blocks
- The export-script view writes plain text directly instead of going
through a JSP
- `PageConfig.makeId()` rejects invalid prefixes
- `LabKeyCollectors.joining()` keeps delimiters next to empty elements
and when combining parallel results
- `HtmlStringBuilder` appends another builder directly, without copying
it into an intermediate `HtmlString`
- Minor cleanups in `ReturnUrlForm` and the devtools module
- The analytics tracking script is returned as trusted HTML from the
service instead of being passed to `unsafe()` by each page template

Verified with `-PerrorProne` compiles of the api, core, and search
modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local
server, `AbstractExportTest`, and manual checks of the folder type,
search, and export script pages.
@labkey-adam
labkey-adam deleted the fb_unsafe branch November 21, 2026 05:35
labkey-adam added a commit to LabKey/customModules that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- `JspBase.unsafe()` requires a compile-time constant, and its
`CharSequence` overload is removed
- JSPs that built markup from strings now use `HtmlString`, `h()`, link
and button builders, or JavaScript-safe encoding (`q()`, JSON) inside
script blocks
- The export-script view writes plain text directly instead of going
through a JSP
- `PageConfig.makeId()` rejects invalid prefixes
- `LabKeyCollectors.joining()` keeps delimiters next to empty elements
and when combining parallel results
- Minor cleanups in `ReturnUrlForm` and the devtools module
- Specimen visit report cells are built as `HtmlString`, with links
built from `ActionURL` and `LinkBuilder` instead of query strings and
hand-coded tags
- The specimen display-settings enum renders itself directly, and the
remaining specimen pages encode plain-text values with `h()`

Verified with `-PerrorProne` compiles of the api, core, and search
modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local
server, `AbstractExportTest`, and manual checks of the folder type,
search, and export script pages.
labkey-adam added a commit to LabKey/commonAssays that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- `JspBase.unsafe()` requires a compile-time constant, and its
`CharSequence` overload is removed
- JSPs that built markup from strings now use `HtmlString`, `h()`, link
and button builders, or JavaScript-safe encoding (`q()`, JSON) inside
script blocks
- The export-script view writes plain text directly instead of going
through a JSP
- `PageConfig.makeId()` rejects invalid prefixes
- `LabKeyCollectors.joining()` keeps delimiters next to empty elements
and when combining parallel results
- Minor cleanups in `ReturnUrlForm` and the devtools module
- Flow compensation, analysis-import, and run-import pages encode
workspace subset names and the graph-size preference, and build their
selects and image markup with builders instead of passing strings to
`unsafe()` or hand-written tags
- The ms2 search-defaults editors encode their configuration XML, and
the remaining flow, luminex, and ms2 pages encode plain-text values

Verified with `-PerrorProne` compiles of the api, core, and search
modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local
server, `AbstractExportTest`, and manual checks of the folder type,
search, and export script pages.
labkey-adam added a commit to LabKey/ehrModules that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- `JspBase.unsafe()` requires a compile-time constant, and its
`CharSequence` overload is removed
- JSPs that built markup from strings now use `HtmlString`, `h()`, link
and button builders, or JavaScript-safe encoding (`q()`, JSON) inside
script blocks
- The export-script view writes plain text directly instead of going
through a JSP
- `PageConfig.makeId()` rejects invalid prefixes
- `LabKeyCollectors.joining()` keeps delimiters next to empty elements
and when combining parallel results
- Minor cleanups in `ReturnUrlForm` and the devtools module

Verified with `-PerrorProne` compiles of the api, core, and search
modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local
server, `AbstractExportTest`, and manual checks of the folder type,
search, and export script pages.
labkey-adam added a commit to LabKey/MacCossLabModules that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- The LINCS download tracking check works with the analytics tracking
script now being returned as HTML
- The Skyline tool store builds its Download and Documentation button
labels with `HtmlStringBuilder` instead of passing concatenated markup
to `unsafe()`

Not compiled locally because this module isn't in my build; checked with
IntelliJ inspections.
labkey-adam added a commit to LabKey/LabDevKitModules that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/testAutomation#3314
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- The laboratory data browser passes its filter types to the page as
JSON instead of hand-built, HTML-encoded script text

Not compiled or tested locally because the laboratory module isn't in my
build.
labkey-adam added a commit to LabKey/testAutomation that referenced this pull request Nov 21, 2026
## Rationale
This PR makes `JspBase.unsafe()` accept only compile-time constants, so
JSPs can no longer write dynamic strings to the page without encoding
them. Error Prone enforces the new `@CompileTimeConstant` annotation,
and this PR converts the callers that passed dynamic strings in the most
common patterns. About 75 non-constant callers remain for follow-up
work, nearly all in platform; they fail only in builds run with
`-PerrorProne`.

## Related Pull Requests
- LabKey/platform#8370
- LabKey/commonAssays#1115
- LabKey/customModules#295
- LabKey/ehrModules#1250
- LabKey/premiumModules#877
- LabKey/LabDevKitModules#332
- LabKey/internalModules#177
- LabKey/clientModules#158
- LabKey/MacCossLabModules#695
- LabKey/targetedms#1310
- LabKey/wnprc-modules#1095

## Changes
- `JspBase.unsafe()` requires a compile-time constant, and its
`CharSequence` overload is removed
- JSPs that built markup from strings now use `HtmlString`, `h()`, link
and button builders, or JavaScript-safe encoding (`q()`, JSON) inside
script blocks
- The export-script view writes plain text directly instead of going
through a JSP
- `PageConfig.makeId()` rejects invalid prefixes
- `LabKeyCollectors.joining()` keeps delimiters next to empty elements
and when combining parallel results
- Minor cleanups in `ReturnUrlForm` and the devtools module
- The dumbster mail page builds its header list with
`HtmlStringBuilder`, and it and the crawler injection page mark their
deliberately raw HTML with an explicit `HtmlString.unsafe()`

Verified with `-PerrorProne` compiles of the api, core, and search
modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local
server, `AbstractExportTest`, and manual checks of the folder type,
search, and export script pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants