license: fix some imports of BUSL-1.1 in MPL-2.0 (#19832)

Some packages licensed under MPL-2.0 were incorrectly importing code
from packages licensed under BUSL-1.1.

Not all imports are fixed here as they will require additional work to
untangle them. To help track progress this commit adds a Semgrep rule
that detects incorrect BUSL-1.1 imports in MPL-2.0 packages.
This commit is contained in:
Luiz Aoqui
2024-01-29 12:04:12 -05:00
committed by GitHub
parent 10324566ae
commit 41277f823f
29 changed files with 2708 additions and 16 deletions

54
.semgrep/mpl_busl.yml Normal file
View File

@@ -0,0 +1,54 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
rules:
- id: "mpl_busl"
patterns:
- pattern-either:
- pattern-inside: |
...
// SPDX-License-Identifier: MPL-2.0
...
package $A
...
import (
...
...
)
...
- pattern-inside: |
...
// SPDX-License-Identifier: MPL-2.0
...
package $A
...
import ...
...
- pattern: |
"github.com/hashicorp/nomad/$...B"
- metavariable-pattern:
metavariable: $...B
patterns:
# List of MPL-2.0 packages that are allowed to be imported.
# Command to find packages:
# find . -name LICENSE ! -path '*node_modules*' | sort
- pattern-not: "api..."
- pattern-not: "demo..."
- pattern-not: "drivers/shared..."
- pattern-not: "helper/crypto..."
- pattern-not: "helper/grpc-middleware..."
- pattern-not: "helper/pluginutils/grpcutils..."
- pattern-not: "helper/pluginutils/hclspecutils..."
- pattern-not: "helper/pointer..."
- pattern-not: "helper/testlog..."
- pattern-not: "helper/uuid..."
- pattern-not: "jobspec..."
- pattern-not: "jobspec2..."
- pattern-not: "plugins..."
message: "BUSL package `github.com/hashicorp/nomad/$...B` imported in MPL package `$A`"
languages:
- "generic"
paths:
exclude:
- "*_test.go"
severity: "ERROR"