GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge branch '4.2' into fix/http-response-reason-phrase-control-chars · netty/netty@167a209

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .claude/commands
    • ghsa-dedupe.md
  • buffer/src
    • main/java/io/netty/buffer
      • ByteBufUtil.java
    • test/java/io/netty/buffer
      • ByteBufUtilTest.java
  • codec-classes-quic/src
    • main/java/io/netty/handler/codec/quic
      • QuicSslContextBuilder.java
      • QuicStreamIdGenerator.java
      • QuicheQuicChannel.java
      • QuicheQuicSslContext.java
      • QuicheQuicStreamChannel.java
    • test/java/io/netty/handler/codec/quic
      • QuicStreamIdGeneratorTest.java
  • codec-compression/src
    • main/java/io/netty/handler/codec/compression
      • Bzip2Decoder.java
      • Bzip2HuffmanStageDecoder.java
    • test/java/io/netty/handler/codec/compression
      • Bzip2DecoderTest.java
      • Bzip2MalformedStreams.java
  • codec-http2/src
    • main/java/io/netty/handler/codec/http2
      • DefaultHttp2HeadersEncoder.java
      • DefaultHttp2RemoteFlowController.java
      • ReadOnlyHttp2Headers.java
    • test/java/io/netty/handler/codec/http2
      • ReadOnlyHttp2HeadersTest.java
  • codec-http3/src
    • main/java/io/netty/handler/codec/http3
      • Http3HeadersSink.java
    • test/java/io/netty/handler/codec/http3
      • Http3HeadersSinkTest.java
  • codec-http/src
    • main/java/io/netty/handler/codec/http
      • HttpContentCompressor.java
      • QueryStringEncoder.java
      • multipart
        • DiskAttribute.java
      • websocketx/extensions
        • WebSocketClientExtensionHandler.java
    • test/java/io/netty/handler/codec/http
      • HttpContentCompressorOptionsTest.java
      • HttpContentCompressorTest.java
      • QueryStringEncoderTest.java
      • multipart
        • DefaultHttpDataFactoryTest.java
      • websocketx/extensions
        • WebSocketClientExtensionHandlerTest.java
  • codec-mqtt/src
    • main/java/io/netty/handler/codec/mqtt
      • MqttDecoder.java
    • test/java/io/netty/handler/codec/mqtt
      • MqttCodecTest.java
  • codec-native-quic/src/test/java/io/netty/handler/codec/quic
    • QuicSslContextTest.java
    • QuicStreamLimitTest.java
    • QuicStreamResetTest.java
  • codec-socks/src
    • main/java/io/netty/handler/codec/socksx/v5
      • DefaultSocks5InitialRequest.java
      • Socks5PrivateAuthRequestDecoder.java
    • test/java/io/netty/handler/codec/socksx/v5
      • Socks5PrivateAuthRequestDecoderTest.java
  • common/src
    • main/java/io/netty/util
      • SecureObjectIdentityHash.java
      • internal
        • BoundedInputStream.java
        • MacAddressUtil.java
        • StringUtil.java
        • WeakIdentityHashMap.java
    • test/java/io/netty/util
      • SecureObjectIdentityHashTest.java
      • internal
        • WeakIdentityHashMapTest.java
  • handler/src
    • main/java/io/netty/handler/ssl
      • ApplicationProtocolNegotiationHandler.java
      • OpenSslServerContext.java
      • ReferenceCountedOpenSslServerContext.java
      • SessionIdContextBuilder.java
      • SslContext.java
      • SslContextBuilder.java
      • SslHandler.java
    • test/java/io/netty/handler/ssl
      • ApplicationProtocolNegotiationHandlerTest.java
      • SslContextSessionIdContextTest.java
      • SslHandlerWrapBackpressureTest.java
  • microbench/src/main/java/io/netty/microbench/handler/ssl
    • SslHandlerSlowTransportBenchmark.java
  • pom.xml
  • resolver-dns/src
    • main/java/io/netty/resolver/dns
      • DnsQueryContextManager.java
    • test/java/io/netty/resolver/dns
      • DnsQueryContextManagerTest.java
      • TestDnsServer.java
  • scripts/ghsa
    • check-freshness.sh
    • extract-index.py
    • linkify.py
  • transport-classes-io_uring/src/main/java/io/netty/channel/uring
    • AbstractIoUringStreamChannel.java
  • transport-native-io_uring/src
    • main/c
      • netty_io_uring_native.c
    • test/java/io/netty/channel/uring
      • IoUringFileRegionProviderTest.java
  • transport-native-unix-common/src/main/java/io/netty/channel/unix
    • UnixChannelUtil.java
  • transport/src
    • main/java/io/netty/channel
      • AbstractChannel.java
      • DefaultFileRegion.java
      • SingleThreadIoEventLoop.java
      • nio
        • NioIoHandler.java
      • socket/nio
        • NioDatagramChannel.java
    • test/java/io/netty/channel/nio
      • NioEventLoopShutdownTest.java

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.claude/commands/ghsa-dedupe.md‎

Copy file name to clipboard
+192Lines changed: 192 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
description: Find duplicate reports among the GitHub private vulnerability (GHSA) exports and write .github/ghsa/ghsa-dupes.md
3+
argument-hint: "[use existing files]"
4+
allowed-tools: Bash(scripts/ghsa/*), Bash(scripts/collect-ghsa-reports.sh), Read, Write, Edit, Agent
5+
---
6+
7+
# GHSA Duplicate Detection
8+
9+
Find duplicate reports among the GitHub private vulnerability (GHSA) exports in
10+
`.github/ghsa`. The output of a run is `.github/ghsa/ghsa-dupes.md`.
11+
12+
All paths are relative to the repository root; run the scripts from there. The helper
13+
scripts live in `scripts/ghsa/` and are run as-is -- **do not rewrite or inline them**.
14+
15+
User arguments: `$ARGUMENTS`
16+
17+
## Goal
18+
19+
Given the JSON exports of GitHub Security Advisory reports (in `triage` and `draft`
20+
states), identify clusters of reports that describe the **same underlying vulnerability**,
21+
so they can be de-duplicated during triage. The `published` advisories are searched as
22+
well, but only in one direction: an open report may turn out to duplicate something already
23+
published. Published advisories are set in stone and are never changed by this exercise.
24+
25+
**Definition of a true duplicate** (the bar every cluster must clear):
26+
27+
> Two or more reports share the **same root cause** AND the **same vulnerable code
28+
> location / function** AND essentially the **same attack and impact**.
29+
30+
Explicitly **not** duplicates:
31+
- Same component/file but a *different* function or root cause.
32+
- Different protocol or code path (e.g. HTTP/1 codec-http vs HTTP/2 codec-http2) even if
33+
the *class* of bug is identical ("sibling" findings).
34+
- Most "incomplete fix" variants -- they usually target a different code path than the
35+
original. Only group them if they point at the same line / root cause.
36+
37+
When in doubt, keep them separate and add a note. It is cheaper to under-merge (flag an
38+
overlap for a human) than to wrongly collapse two distinct vulnerabilities.
39+
40+
## Inputs
41+
42+
- `.github/ghsa/triage/GHSA-*.json` -- reports in the triage state.
43+
- `.github/ghsa/draft/GHSA-*.json` -- reports in the draft state.
44+
- `.github/ghsa/published/GHSA-*.json` -- published advisories, read-only reference: an open
45+
report matching one of these is a re-report of a known CVE.
46+
47+
`.github/ghsa/closed/*.json` is **not** an input. Closed reports were already dispositioned
48+
as duplicates or as not relevant, and a real duplicate of one would have its original in
49+
`draft` or `published` anyway.
50+
51+
All three input directories share the same JSON schema. Each file is named
52+
`<GHSA-ID>.json`. Relevant fields:
53+
54+
| Field | Use |
55+
|-------|-----|
56+
| `ghsa_id` | Identity. |
57+
| `summary` | One-line title -- primary clustering signal. |
58+
| `description` | Full technical detail: root cause, vulnerable file/function, PoC, fix. **This is what confirms a duplicate.** |
59+
| `vulnerabilities[].package` + `vulnerable_version_range` | Component -- primary clustering signal. |
60+
| `cwe_ids` | Weak signal for clustering. |
61+
| `created_at` | Ordering within a cluster (oldest = presumptive original). |
62+
| `author.login` | Provenance; helps spot maintainer-authored drafts. |
63+
| `state` | `triage` / `draft` (open, actionable) vs `published` (reference only). |
64+
| `cve_id` | Set on published advisories -- the handle to cite when an open report duplicates one. |
65+
66+
The bulk of each file is author/URL boilerplate -- ignore it.
67+
68+
## Why not just read everything
69+
70+
At over 150 reports and several MB of raw JSON, the full corpus is large and mostly boilerplate.
71+
The efficient path is: **extract a tiny index, cluster from the index, then read only the
72+
full descriptions of candidate clusters** (fan out to sub-agents so no single context
73+
holds all descriptions).
74+
75+
## Procedure
76+
77+
### Step 0 -- Make sure the extracted reports are fresh
78+
79+
1. Run `scripts/ghsa/check-freshness.sh`. It exits 0 if every extracted `GHSA-*.json` file is
80+
at most 4 hours old (override with `GHSA_MAX_AGE_MINUTES`), 1 if some file is older, and 2 if
81+
there are no files at all.
82+
2. Exit 0: continue to step 1.
83+
3. Exit 1 or 2: run `scripts/collect-ghsa-reports.sh`. It needs `gh` (authenticated against
84+
`netty/netty` with access to security advisories) and `jq`, and it first deletes every
85+
`*.json` file under `.github/ghsa` before re-downloading, so it can take a while.
86+
4. If the collect script succeeds, run `scripts/ghsa/check-freshness.sh` again and continue
87+
only once it exits 0.
88+
5. If the collect script fails (missing tool, no auth, no network, sandbox restrictions, ...),
89+
do not try to work around it. Tell the user what failed and ask them to run it
90+
themselves, then continue once they confirm.
91+
The only exception is when the user explicitly insists on deduplicating the
92+
existing files (including via the arguments above): then skip the refresh, say in the final
93+
report that the data may be outdated, and proceed. Because the script deletes the old files
94+
before downloading, a failed run may leave the directory empty or partial: re-run
95+
`scripts/ghsa/check-freshness.sh` and, if it exits 2, there is nothing to deduplicate, so
96+
the user must run the collect script.
97+
98+
If the user's arguments already say to use the existing files, skip this step.
99+
100+
### Step 1 -- Extract a compact index
101+
102+
Run `python3 scripts/ghsa/extract-index.py`. It walks the three input directories and writes:
103+
104+
- `/tmp/reports.json` -- per report: `ghsa_id`, `state`, `created_at`, `severity`,
105+
`author`, `cve_id`, `cwe_ids`, `packages`, `summary`, `description`. Sorted by `created_at`.
106+
- `/tmp/index.json` -- the same **minus `description`** (the scannable overview).
107+
108+
It prints the number of reports per state; sanity-check that against the directories.
109+
110+
### Step 2 -- Cluster candidates from the index
111+
112+
Read `/tmp/index.json` and group reports into **candidate clusters** by (a) affected
113+
package/component and (b) summary/mechanism. Err toward *over*-grouping here -- this stage
114+
only decides what to read together; false candidates get rejected in step 3.
115+
116+
Cluster **across states**: a `triage` report and a `published` advisory on the same
117+
component belong in the same candidate cluster. Drop any candidate cluster made up
118+
entirely of `published` advisories -- duplicates among those are not actionable. Every
119+
cluster carried into step 3 must contain at least one `triage` or `draft` report.
120+
121+
Watch for these recurring, easy-to-confuse families (they need care in step 3):
122+
- Multiple "incomplete fix of CVE-XXXX" reports on the same component.
123+
- Protocol-downgrade / request-smuggling variants (H1/H2/H3, `:authority`/`Host`/`:path`,
124+
Transfer-Encoding, chunk-size parsing).
125+
- `maxAllocation` / decompression-bomb reports across different codecs (br/zstd/snappy,
126+
websocket deflate, bzip2, lz4).
127+
- QPACK / HPACK DoS variants.
128+
129+
### Step 3 -- Confirm clusters by reading full descriptions (fan out)
130+
131+
Split the candidate clusters across several sub-agents (about 4 worked well; keep related
132+
clusters with the same agent so it has the context to judge). Each agent reads the full
133+
`description` of every report in its assigned clusters directly from the JSON files and
134+
returns, per cluster:
135+
136+
1. Which GHSA-IDs are **true duplicates** (grouped), and which stand alone.
137+
2. For every report: `ghsa_id`, `created_at`, `author`, `state`, and `cve_id` if set.
138+
3. A 1-2 sentence rationale citing the **specific shared or differing root cause /
139+
vulnerable function / file**.
140+
141+
Give every agent the same duplicate definition (above). Instruct them to be
142+
evidence-based, to explicitly call out non-duplicates, and to write no files.
143+
144+
**Boundary risk:** duplicates that straddle two agents' assignments can be missed. Keep
145+
topically related clusters (e.g. all request-smuggling variants) with a single agent, and
146+
in the assignment note tell each agent which neighboring reports exist so it can flag a
147+
cross-boundary match.
148+
149+
### Step 4 -- Synthesize the report
150+
151+
Consolidate agent verdicts into `.github/ghsa/ghsa-dupes.md`:
152+
153+
- Keep only confirmed duplicate clusters (2+ reports).
154+
- **Order reports within each cluster by `created_at`, oldest first**; mark the oldest as
155+
"(original)".
156+
- Order the clusters themselves by their oldest member's `created_at`.
157+
- For each cluster: a "Same bug:" paragraph (shared root cause + vulnerable function) and
158+
a table of `created_at | GHSA | state | author`.
159+
- Give clusters where an open report duplicates a `published` advisory their own section --
160+
the disposition is "close as duplicate of <CVE/GHSA>", not a merge of two open reports.
161+
- Add a **"Notable non-duplicates"** section listing the families that were considered and
162+
rejected, with a one-line reason each -- this shows they were examined, not missed.
163+
- Flag caveats inline: near-duplicates/overlaps, reports that bridge two clusters, and
164+
maintainer-authored drafts (which may be the project's own canonical write-up rather than
165+
a true duplicate -- consider which report in a cluster should be called the "original").
166+
- If step 0 was skipped because the user insisted on the existing files, say so at the top
167+
of the report, together with the age of the data if known.
168+
169+
**Never put a GHSA ID in backticks.** A markdown link inside a code span renders as literal
170+
text, not a clickable link. Write GHSA IDs bare and let step 5 wrap them. Backticks are for
171+
code identifiers only (file names, methods, fields); a GHSA ID is neither. Bold is fine:
172+
`**[id](url)**` renders correctly.
173+
174+
### Step 5 -- Linkify and verify
175+
176+
Run `python3 scripts/ghsa/linkify.py`. It makes every `GHSA-####-####-####` reference in
177+
`.github/ghsa/ghsa-dupes.md` a link to the advisory (idempotent), then verifies the result and
178+
prints three counts -- backticked links, double-wrapped links, unlinked IDs. It exits non-zero
179+
unless all three are zero; if it does, fix the markdown and re-run.
180+
181+
## Notes / gotchas
182+
183+
- **`created_at` is the tiebreaker for "original".** But a maintainer's `draft` may be an
184+
internal tracking advisory filed *after* an external report -- note this rather than
185+
blindly calling the earliest the original.
186+
- **Sibling is not duplicate.** The same bug class in codec-http vs codec-http2 vs codec-http3,
187+
or in encode vs decode paths, is almost always two distinct findings.
188+
- **Read the description, not just the summary.** Summaries of distinct bugs often look
189+
near-identical (e.g. several "SmtpResponseDecoder ... DoS" titles that are genuinely the
190+
same, vs several "Transfer-Encoding smuggling" titles that are not).
191+
- Re-running is cheap: only the contents of the input directories change between runs.
192+
Re-run step 0, regenerate the index and repeat.
Collapse file

‎buffer/src/main/java/io/netty/buffer/ByteBufUtil.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,8 @@ private static int safeDirectWriteUtf8(ByteBuffer buffer, int writerIndex, CharS
985985
char c2 = seq.charAt(i);
986986
if (!Character.isLowSurrogate(c2)) {
987987
buffer.put(writerIndex++, WRITE_UTF_UNKNOWN);
988-
buffer.put(writerIndex++, Character.isHighSurrogate(c2)? WRITE_UTF_UNKNOWN : (byte) c2);
988+
// c has no low surrogate, so encode c2 on its own in the next iteration.
989+
i--;
989990
} else {
990991
int codePoint = Character.toCodePoint(c, c2);
991992
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
@@ -1032,7 +1033,8 @@ private static int safeWriteUtf8(AbstractByteBuf buffer, int writerIndex, CharSe
10321033
char c2 = seq.charAt(i);
10331034
if (!Character.isLowSurrogate(c2)) {
10341035
buffer._setByte(writerIndex++, WRITE_UTF_UNKNOWN);
1035-
buffer._setByte(writerIndex++, Character.isHighSurrogate(c2)? WRITE_UTF_UNKNOWN : c2);
1036+
// c has no low surrogate, so encode c2 on its own in the next iteration.
1037+
i--;
10361038
} else {
10371039
int codePoint = Character.toCodePoint(c, c2);
10381040
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
@@ -1075,7 +1077,8 @@ private static int safeArrayWriteUtf8(byte[] buffer, int writerIndex, CharSequen
10751077
// and increase the chance to inline CharSequence::charAt instead
10761078
if (!Character.isLowSurrogate(c2)) {
10771079
buffer[writerIndex++] = WRITE_UTF_UNKNOWN;
1078-
buffer[writerIndex++] = (byte) (Character.isHighSurrogate(c2)? WRITE_UTF_UNKNOWN : c2);
1080+
// c has no low surrogate, so encode c2 on its own in the next iteration.
1081+
i--;
10791082
} else {
10801083
int codePoint = Character.toCodePoint(c, c2);
10811084
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
@@ -1121,8 +1124,8 @@ private static int unsafeWriteUtf8(byte[] buffer, long memoryOffset, int writerI
11211124
// and increase the chance to inline CharSequence::charAt instead
11221125
if (!Character.isLowSurrogate(c2)) {
11231126
PlatformDependent.putByte(buffer, writerOffset++, WRITE_UTF_UNKNOWN);
1124-
PlatformDependent.putByte(buffer, writerOffset++,
1125-
(byte) (Character.isHighSurrogate(c2)? WRITE_UTF_UNKNOWN : c2));
1127+
// c has no low surrogate, so encode c2 on its own in the next iteration.
1128+
i--;
11261129
} else {
11271130
int codePoint = Character.toCodePoint(c, c2);
11281131
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
@@ -1212,8 +1215,9 @@ private static int utf8BytesNonAscii(final CharSequence seq, final int start, fi
12121215
break;
12131216
}
12141217
if (!Character.isLowSurrogate(seq.charAt(i))) {
1215-
// WRITE_UTF_UNKNOWN + (Character.isHighSurrogate(c2) ? WRITE_UTF_UNKNOWN : c2)
1216-
encodedLength += 2;
1218+
// WRITE_UTF_UNKNOWN, the next character is counted on its own in the next iteration
1219+
encodedLength++;
1220+
i--;
12171221
continue;
12181222
}
12191223
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G2630.
Collapse file

‎buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java‎

Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,28 @@ public void testWriteUtf8InvalidEndOnTrailingSurrogate(BufferType bufferType) {
734734
buf2.release();
735735
}
736736

737+
@ParameterizedTest(name = PARAMETERIZED_NAME)
738+
@MethodSource("noUnsafe")
739+
public void testWriteUtf8InvalidLeadingSurrogateFollowedByNonAscii(BufferType bufferType) {
740+
// The character after an unpaired leading surrogate must still be encoded, like the JDK does.
741+
checkWriteUtf8SameAsJdk(bufferType, "a\uD800\u00E9b");
742+
checkWriteUtf8SameAsJdk(bufferType, "a\uD800\u4E2Db");
743+
checkWriteUtf8SameAsJdk(bufferType, "a\uD800\uD83D\uDE00b");
744+
}
745+
746+
private void checkWriteUtf8SameAsJdk(BufferType bufferType, String seq) {
747+
ByteBuf expected = Unpooled.wrappedBuffer(seq.getBytes(CharsetUtil.UTF_8));
748+
ByteBuf buf = buffer(bufferType, 16);
749+
try {
750+
ByteBufUtil.writeUtf8(buf, seq);
751+
assertEquals(ByteBufUtil.hexDump(expected), ByteBufUtil.hexDump(buf));
752+
assertEquals(expected.readableBytes(), ByteBufUtil.utf8Bytes(seq));
753+
} finally {
754+
buf.release();
755+
expected.release();
756+
}
757+
}
758+
737759
@ParameterizedTest(name = PARAMETERIZED_NAME)
738760
@MethodSource("noUnsafe")
739761
public void testWriteUsAsciiString(BufferType bufferType) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.