Skip to content

Commit 3198a86

Browse files
a-orenclaude
andcommitted
fix(go): drop support for old space-separated exhortignore format in indirect deps
The old format (// indirect exhortignore) is no longer supported — only the semicolon format (// indirect; exhortignore) is accepted. This aligns with the JS client and avoids issues with go mod tidy mangling comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1a098cc commit 3198a86

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/main/java/io/github/guacsec/trustifyda/providers/GoModulesProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public boolean IgnoredLine(String line) {
567567
// then this line is to be checked if it's a comment after a package name.
568568
if (Pattern.matches(".+//\\s*(exhortignore|trustify-da-ignore)", line)
569569
|| Pattern.matches(
570-
".+//\\s*indirect\\s*;?\\s*(//)?\\s*(exhortignore|trustify-da-ignore)", line)) {
570+
".+//\\s*indirect\\s*;\\s*(//)?\\s*(exhortignore|trustify-da-ignore)", line)) {
571571
String trimmedRow = line.trim();
572572
// filter out lines where exhortignore or trustify-da-ignore has no meaning
573573
if (!trimmedRow.startsWith("module ")

src/test/java/io/github/guacsec/trustifyda/providers/Golang_Modules_Provider_Test.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,32 @@ void Test_Golang_MvS_Enabled_Preserves_All_Transitive_Dependencies() throws IOEx
229229
+ "getFinalPackagesVersionsForModule() is losing transitive dependencies.");
230230
}
231231

232+
@Test
233+
void test_IgnoredLine_rejects_old_space_separated_indirect_format() {
234+
var provider = new GoModulesProvider(Path.of("go.mod"));
235+
// Old format (space-separated, no semicolon) should NOT be recognized
236+
assertThat(
237+
provider.IgnoredLine(
238+
" github.com/foo/bar v1.0.0 // indirect trustify-da-ignore"))
239+
.isFalse();
240+
assertThat(provider.IgnoredLine(" github.com/foo/bar v1.0.0 // indirect exhortignore"))
241+
.isFalse();
242+
// New semicolon format should still be recognized
243+
assertThat(
244+
provider.IgnoredLine(
245+
" github.com/foo/bar v1.0.0 // indirect; trustify-da-ignore"))
246+
.isTrue();
247+
assertThat(provider.IgnoredLine(" github.com/foo/bar v1.0.0 // indirect; exhortignore"))
248+
.isTrue();
249+
assertThat(
250+
provider.IgnoredLine(
251+
" github.com/foo/bar v1.0.0 // indirect; //trustify-da-ignore"))
252+
.isTrue();
253+
assertThat(
254+
provider.IgnoredLine(" github.com/foo/bar v1.0.0 // indirect; //exhortignore"))
255+
.isTrue();
256+
}
257+
232258
@Test
233259
void test_isGoToolchainEntry_filters_go_and_toolchain() {
234260
// go@* entries should be filtered

0 commit comments

Comments
 (0)