From cab510f5324d153d450707162a7bb5c0306040a0 Mon Sep 17 00:00:00 2001 From: Percy Wegmann Date: Thu, 12 Sep 2024 13:27:57 -0500 Subject: [PATCH] check for license headers in CI Also update license information to reflect latest authors. Updates #cleanup Signed-off-by: Percy Wegmann --- .github/workflows/ci.yml | 8 ++++ LICENSE | 1 + scripts/check_license_headers.sh | 77 ++++++++++++++++++++++++++++++++ tailscale/client.go | 3 ++ tailscale/client_test.go | 3 ++ tailscale/tailscale_test.go | 3 ++ tailscale/time_test.go | 3 ++ v2/README.md | 3 ++ v2/client.go | 3 ++ v2/client_test.go | 3 ++ v2/contacts.go | 3 ++ v2/contacts_test.go | 3 ++ v2/device_posture.go | 3 ++ v2/device_posture_test.go | 3 ++ v2/devices.go | 3 ++ v2/devices_test.go | 3 ++ v2/dns.go | 3 ++ v2/dns_test.go | 3 ++ v2/keys.go | 3 ++ v2/keys_test.go | 3 ++ v2/logging.go | 3 ++ v2/logging_test.go | 3 ++ v2/policyfile.go | 3 ++ v2/policyfile_test.go | 3 ++ v2/tailnet_settings.go | 3 ++ v2/tailnet_settings_test.go | 3 ++ v2/tailscale_test.go | 3 ++ v2/users.go | 3 ++ v2/users_test.go | 3 ++ v2/webhooks.go | 3 ++ v2/webhooks_test.go | 3 ++ 31 files changed, 170 insertions(+) create mode 100755 scripts/check_license_headers.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0a4fa1..2307dad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,3 +31,11 @@ jobs: - name: Run tests run: go test -race ./... + + licenses: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: check licenses + run: ./scripts/check_license_headers.sh . diff --git a/LICENSE b/LICENSE index 8da1cf0..6e85423 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2021 David Bond +Copyright (c) 2024 Tailscale Inc & Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/scripts/check_license_headers.sh b/scripts/check_license_headers.sh new file mode 100755 index 0000000..7d099c9 --- /dev/null +++ b/scripts/check_license_headers.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# +# Copyright (c) David Bond, Tailscale Inc, & Contributors +# SPDX-License-Identifier: MIT + +# check_license_headers.sh checks that all Go files in the given +# directory tree have a correct-looking license header. + +check_file() { + got=$1 + + want=$(cat <&2 + exit 1 +fi + +fail=0 +for file in $(find $1 \( -name '*.go' -or -name '*.tsx' -or -name '*.ts' -not -name '*.config.ts' \) -not -path '*/.git/*' -not -path '*/node_modules/*'); do + case $file in + $1/tempfork/*) + # Skip, tempfork of third-party code + ;; + $1/wgengine/router/ifconfig_windows.go) + # WireGuard copyright. + ;; + $1/cmd/tailscale/cli/authenticode_windows.go) + # WireGuard copyright. + ;; + *_string.go) + # Generated file from go:generate stringer + ;; + $1/control/controlbase/noiseexplorer_test.go) + # Noiseexplorer.com copyright. + ;; + */zsyscall_windows.go) + # Generated syscall wrappers + ;; + $1/util/winutil/subprocess_windows_test.go) + # Subprocess test harness code + ;; + $1/util/winutil/testdata/testrestartableprocesses/main.go) + # Subprocess test harness code + ;; + *$1/k8s-operator/apis/v1alpha1/zz_generated.deepcopy.go) + # Generated kube deepcopy funcs file starts with a Go build tag + an empty line + header="$(head -5 $file | tail -n+3 )" + ;; + $1/derp/xdp/bpf_bpfe*.go) + # Generated eBPF management code + ;; + *) + header="$(head -2 $file)" + ;; + esac + if [ ! -z "$header" ]; then + if ! check_file "$header"; then + fail=1 + echo "${file#$1/} doesn't have the right copyright header:" + echo "$header" | sed -e 's/^/ /g' + fi + fi +done + +if [ $fail -ne 0 ]; then + exit 1 +fi diff --git a/tailscale/client.go b/tailscale/client.go index 8d4dc71..15d5bac 100644 --- a/tailscale/client.go +++ b/tailscale/client.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + // Package tailscale contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here: // https://github.com/tailscale/tailscale/blob/main/api.md package tailscale diff --git a/tailscale/client_test.go b/tailscale/client_test.go index 1a3affc..b1efc9b 100644 --- a/tailscale/client_test.go +++ b/tailscale/client_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tailscale_test import ( diff --git a/tailscale/tailscale_test.go b/tailscale/tailscale_test.go index 933522f..4394127 100644 --- a/tailscale/tailscale_test.go +++ b/tailscale/tailscale_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tailscale_test import ( diff --git a/tailscale/time_test.go b/tailscale/time_test.go index 9d008d5..a4f8687 100644 --- a/tailscale/time_test.go +++ b/tailscale/time_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tailscale_test import ( diff --git a/v2/README.md b/v2/README.md index 04bf158..90c2a1c 100644 --- a/v2/README.md +++ b/v2/README.md @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + # tailscale-client-go/v2 [![Go Reference](https://pkg.go.dev/badge/github.com/tailscale/tailscale-client-go/v2.svg)](https://pkg.go.dev/github.com/tailscale/tailscale-client-go/v2) diff --git a/v2/client.go b/v2/client.go index 351f124..ba9bd0f 100644 --- a/v2/client.go +++ b/v2/client.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + // Package tsclient contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here: // https://tailscale.com/api package tsclient diff --git a/v2/client_test.go b/v2/client_test.go index 26b7530..0fd5038 100644 --- a/v2/client_test.go +++ b/v2/client_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/contacts.go b/v2/contacts.go index 74fcc5f..3da5152 100644 --- a/v2/contacts.go +++ b/v2/contacts.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/contacts_test.go b/v2/contacts_test.go index b6188e6..430436e 100644 --- a/v2/contacts_test.go +++ b/v2/contacts_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/device_posture.go b/v2/device_posture.go index 56b9a83..917b957 100644 --- a/v2/device_posture.go +++ b/v2/device_posture.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/device_posture_test.go b/v2/device_posture_test.go index 4bf6b9c..7703346 100644 --- a/v2/device_posture_test.go +++ b/v2/device_posture_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/devices.go b/v2/devices.go index 6a0f850..cad391d 100644 --- a/v2/devices.go +++ b/v2/devices.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/devices_test.go b/v2/devices_test.go index b1f4635..697ea07 100644 --- a/v2/devices_test.go +++ b/v2/devices_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/dns.go b/v2/dns.go index 9e28db4..c3c2ec2 100644 --- a/v2/dns.go +++ b/v2/dns.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/dns_test.go b/v2/dns_test.go index 01a0fcc..562c0f1 100644 --- a/v2/dns_test.go +++ b/v2/dns_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/keys.go b/v2/keys.go index 7586eaa..a251fbf 100644 --- a/v2/keys.go +++ b/v2/keys.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/keys_test.go b/v2/keys_test.go index 2a9dc9a..0ad7e17 100644 --- a/v2/keys_test.go +++ b/v2/keys_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/logging.go b/v2/logging.go index 26a27c9..3489be5 100644 --- a/v2/logging.go +++ b/v2/logging.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/logging_test.go b/v2/logging_test.go index 6bb9cfc..f741157 100644 --- a/v2/logging_test.go +++ b/v2/logging_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/policyfile.go b/v2/policyfile.go index a131b64..04b0c41 100644 --- a/v2/policyfile.go +++ b/v2/policyfile.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/policyfile_test.go b/v2/policyfile_test.go index 8aa51e9..4ca1cc4 100644 --- a/v2/policyfile_test.go +++ b/v2/policyfile_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/tailnet_settings.go b/v2/tailnet_settings.go index af0357a..8c39341 100644 --- a/v2/tailnet_settings.go +++ b/v2/tailnet_settings.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/tailnet_settings_test.go b/v2/tailnet_settings_test.go index ba9c2d3..393676c 100644 --- a/v2/tailnet_settings_test.go +++ b/v2/tailnet_settings_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/tailscale_test.go b/v2/tailscale_test.go index 985310c..f7d2915 100644 --- a/v2/tailscale_test.go +++ b/v2/tailscale_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/users.go b/v2/users.go index 1cbccd5..e88b94a 100644 --- a/v2/users.go +++ b/v2/users.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/users_test.go b/v2/users_test.go index a184d77..4bb94cd 100644 --- a/v2/users_test.go +++ b/v2/users_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import ( diff --git a/v2/webhooks.go b/v2/webhooks.go index 7454e63..1547f80 100644 --- a/v2/webhooks.go +++ b/v2/webhooks.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient import ( diff --git a/v2/webhooks_test.go b/v2/webhooks_test.go index 3e4dca0..4508f82 100644 --- a/v2/webhooks_test.go +++ b/v2/webhooks_test.go @@ -1,3 +1,6 @@ +// Copyright (c) David Bond, Tailscale Inc, & Contributors +// SPDX-License-Identifier: MIT + package tsclient_test import (