Skip to content

fix(submit): reject a standard license with a restriction tacked on - #207

Merged
jamesconwaydev merged 2 commits into
devstreamhq:mainfrom
foothillsdigital:fix/licence-added-restrictions
Nov 6, 2026
Merged

jamesconwaydev merged 2 commits into
devstreamhq:mainfrom
foothillsdigital:fix/licence-added-restrictions

Conversation

@foothillsdigital

Copy link
Copy Markdown
Collaborator

What and why

Closes #42.

Licence detection matched a file by the licence's own phrases, so the MIT text plus "you may not use this commercially" read as MIT. Now, once a licence file is recognised (by phrase, SPDX line or the one-line MIT), _detect_text also checks the whole file for added restriction wording, and so does the README ## License section path. A hit fails with the existing non-OSI message: "This repo's license (MIT with an added restriction) isn't an open-source license, so it can't be listed." The reason is a fixed string built from the SPDX ID and never quotes the file, since bot comments are public.

RESTRICTION_RE only catches wording that restricts:

  • may not / can't / must not be used, sold or distributed … commercially
  • may not be sold or resold
  • commercial use is prohibited, not permitted, or forbidden
  • no commercial use
  • commercial use requires a (paid) licence
  • personal, private, educational, academic or non-commercial use only

I first tried "any sentence with commercial and a negation", and it flagged GPL-3, AGPL, LGPL, Apache, EPL and Artistic, which all mention commercial use without limiting it. A new test runs every fixture through the check: all pass except CC BY-NC, which really does restrict, and isn't OSI anyway. The [^.;]{0,40} gaps are bounded, the existing hostile-input tests are unchanged, and the full suite is ~2.5s.

One gap: this only runs when GitHub's own detection comes up empty (NOASSERTION/NONE). A modified MIT text normally lands there, since licensee won't match a changed text, so I left GitHub's positive answers alone.

Checks

  • The PR title follows Conventional Commits
  • python3 -m unittest discover -s scripts -t . passes (595; the new tests fail on main)
  • npm --prefix site test passes (if you touched site/)
  • npx prettier --check . passes
  • This doesn't edit data/entries.json by hand (submissions go through the form)

@jamesconwaydev jamesconwaydev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patterns are careful, and running every fixture through them is exactly the test I'd have asked for. Two things before it goes in:

1. Dry-run it against the current list. A licence fail removes an entry straight away, with no 30-day warning, and the weekly health check runs this on all 454 entries. The new path only fires when GitHub's detection is NOASSERTION/NONE, which is the case for a handful of listed repos (postgres, perl5 and ruby all came in through the fallback). Could you run check_repo(..., "rot") with your own token for every listed entry whose GitHub licence is NOASSERTION, NONE or missing, and paste the result in the PR? Anything that passes on main but fails here needs a look before merge. Fetching the licence key in a GraphQL batch first keeps it to a few dozen calls.

2. "No commercial use" in README prose. The README ## License path reads free text, so no commercial use also hits "There are no commercial use restrictions". The same goes for commercial use … requires, as in "commercial use requires nothing more than the notice". Please skip a match when restriction, limit or fee follows within a few words, or when the requires-clause names attribution or the notice, and add a test for each phrasing.

@foothillsdigital

Copy link
Copy Markdown
Collaborator Author

Dry run against the current list

I checked all 454 listed entries with GET /repos/{r} (REST, since I don't have GraphQL here): 30 have a GitHub licence of NOASSERTION, NONE or missing. I ran check_repo(repo, gh, now, "rot", allowed_extra=extra_licenses_for(category)), the same call rot makes, on main and on this branch with my token.

First pass: 1 difference. mysql/mysql-server went from ok to remove ("Unicode-3.0 with an added restriction"). Its LICENSE bundles the MIT Kerberos notice: "No commercial use of these trademarks may be made without prior written permission of MIT." That limits the use of a trademark, not the licence. Fixed in 717a4c0: a match is skipped when its sentence is about trademarks, trade names, service marks or logos. That exact sentence is now a test, plus one where a real restriction follows it.

After the fix: 30/30 identical to main, all ok.

Result on both Repos
ok, NOASSERTION BerriAI/litellm, certbot/certbot, fail2ban/fail2ban, fleetdm/fleet, gitlabhq/gitlabhq, goauthentik/authentik, Infisical/infisical, intuitem/ciso-assistant-community, langfuse/langfuse, mysql/mysql-server, netbirdio/netbird, nodejs/node, open-webui/open-webui, osquery/osquery, Perl/perl5, postgres/postgres, python/cpython, ruby/ruby, Velocidex/velociraptor, wazuh/wazuh
ok, no licence cockpit-project/cockpit, heynickc/awesome-ddd, lukasz-madon/awesome-remote-job, matiassingers/awesome-readme, MunGell/awesome-for-beginners, qazbnm456/awesome-web-security, Solido/awesome-flutter, sorrycc/awesome-javascript, unicodeveloper/awesome-nextjs, webpro/awesome-dotfiles

README prose (review point 2)

  • no commercial use and commercial use … requires are skipped when restriction(s), limit(s), limitation(s) or fee(s) follows within the clause.
  • The requires-clause is also skipped when it names attribution, notice or credit.
  • New tests cover each phrasing ("There are no commercial use restrictions", "No commercial use limits apply", "Without commercial use fees", "requires nothing more than the notice", "requires attribution", "requires no fee or other limitation"). Two controls still fail: "No commercial use." and "Commercial use requires a paid license."

597 tests pass.

@jamesconwaydev jamesconwaydev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That dry run paid for itself. MySQL would have been pulled on the next health check. The trademark rule is the right cut, and the controls that still fail are what convince me. Thanks.

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

The fuzz failure here wasn't your code. It was a description-cleaner bug from #203 that was already on main, and #208 fixes it. Could you rebase onto main so CI runs clean? I'll merge this once it's green.

A LICENSE that was the MIT text plus "you may not use this
commercially" passed, because the phrase match only looked for MIT's
own wording. Once a license file (by phrase, SPDX line or one-line
name) or a README License section is recognised, it is now also
checked for added restriction wording: may not be used commercially
or sold, commercial use prohibited or needing a paid license, and
personal/educational/non-commercial use only. A hit fails as
"<ID> with an added restriction". The reason is a fixed string and
never quotes the file, since it is posted publicly.

The patterns stick to wording that restricts. A test checks that no
canonical fixture trips them except CC BY-NC, which really does.
@foothillsdigital
foothillsdigital force-pushed the fix/licence-added-restrictions branch from 717a4c0 to 4557a10 Compare November 6, 2026 17:37
@jamesconwaydev
jamesconwaydev merged commit 2f6734d into devstreamhq:main Nov 6, 2026
8 checks passed
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.

Catch prose restrictions inside an OSI licence text

2 participants