Skip to content

Commit

Permalink
tools: add script that checks copyright headers
Browse files Browse the repository at this point in the history
Fixes #1604
  • Loading branch information
dvyukov committed Feb 18, 2020
1 parent 012fbc3 commit 135c18a
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 16 deletions.
11 changes: 8 additions & 3 deletions Makefile
Expand Up @@ -94,7 +94,7 @@ endif
bin/syz-sysgen bin/syz-extract bin/syz-fmt \
extract generate generate_go generate_sys \
format format_go format_cpp format_sys \
tidy test test_race check_links check_diff \
tidy test test_race check_copyright check_links check_diff \
arch arch_darwin_amd64_host arch_linux_amd64_host \
arch_freebsd_amd64_host arch_netbsd_amd64_host \
arch_linux_amd64_target arch_linux_386_target \
Expand Down Expand Up @@ -307,11 +307,13 @@ presubmit:
$(MAKE) generate
$(MAKE) check_diff
$(GO) install ./...
$(MAKE) presubmit_parallel
$(MAKE) check_copyright
$(MAKE) check_links
$(MAKE) lint
$(MAKE) presubmit_parallel
echo LGTM

presubmit_parallel: test test_race arch check_links
presubmit_parallel: test test_race arch

test:
ifeq ("$(TRAVIS)$(shell go version | grep 1.11)", "true")
Expand Down Expand Up @@ -347,6 +349,9 @@ install_prerequisites:
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/dvyukov/go-fuzz/go-fuzz-build

check_copyright:
./tools/check-copyright.sh

check_links:
python ./tools/check_links.py $$(pwd) $$(ls ./*.md; find ./docs/ -name '*.md')

Expand Down
2 changes: 1 addition & 1 deletion pkg/csource/gen.go
Expand Up @@ -52,7 +52,7 @@ func main() {
} {
data = regexp.MustCompile(remove).ReplaceAll(data, nil)
}
fmt.Fprintf(out, "// AUTOGENERATED FROM executor/common.h\n\n")
fmt.Fprintf(out, "// AUTOGENERATED FILE FROM executor/*.h\n\n")
fmt.Fprintf(out, "package csource\n\nvar commonHeader = `\n")
out.Write(data)
fmt.Fprintf(out, "`\n")
Expand Down
2 changes: 1 addition & 1 deletion pkg/csource/generated.go
@@ -1,4 +1,4 @@
// AUTOGENERATED FROM executor/common.h
// AUTOGENERATED FILE FROM executor/*.h

package csource

Expand Down
3 changes: 3 additions & 0 deletions pkg/vcs/git_test_util.go
@@ -1,3 +1,6 @@
// Copyright 2019 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package vcs

import (
Expand Down
3 changes: 3 additions & 0 deletions prog/any.go
@@ -1,3 +1,6 @@
// Copyright 2018 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package prog

import (
Expand Down
3 changes: 2 additions & 1 deletion sys/freebsd/pf.txt
@@ -1,4 +1,5 @@
##
# Copyright 2019 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <sys/param.h>
include <sys/socket.h>
Expand Down
3 changes: 3 additions & 0 deletions sys/fuchsia/ddk.txt
@@ -1,3 +1,6 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <zircon/syscalls.h>
include <zircon/types.h>

Expand Down
3 changes: 3 additions & 0 deletions sys/fuchsia/hypervisor_guests.txt
@@ -1,3 +1,6 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <zircon/syscalls.h>

resource zx_guest[intptr]
Expand Down
3 changes: 1 addition & 2 deletions sys/linux/dev_infiniband_rdma.txt
@@ -1,6 +1,5 @@
# Copyright 2019 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found
# in the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# TODO: This needs some fixups according to PR review:
# https://github.com/google/syzkaller/pull/1053
Expand Down
2 changes: 1 addition & 1 deletion sys/linux/dev_video4linux.txt
@@ -1,5 +1,5 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# Constants for this descriptions were generated on the following tree:
# https://source.codeaurora.org/quic/la/kernel/msm-4.9 msm-4.9
Expand Down
2 changes: 1 addition & 1 deletion sys/linux/mptcp.txt
@@ -1,5 +1,5 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# TCP Extensions for Multipath Operation with Multiple Addresses
# https://tools.ietf.org/html/rfc6824
Expand Down
2 changes: 1 addition & 1 deletion sys/linux/socket_netlink_generic_team.txt
@@ -1,5 +1,5 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be teamnd in the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# AF_NETLINK/NETLINK_GENERIC/team support.

Expand Down
3 changes: 3 additions & 0 deletions sys/openbsd/init_test.go
@@ -1,3 +1,6 @@
// Copyright 2019 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package openbsd_test

import (
Expand Down
3 changes: 3 additions & 0 deletions sys/openbsd/kqueue.txt
@@ -1,3 +1,6 @@
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <sys/types.h>
include <sys/event.h>
include <sys/time.h>
Expand Down
2 changes: 1 addition & 1 deletion sys/windows/windows.txt
@@ -1,4 +1,4 @@
# This was autogenerated with tools/syz-declextract.
# AUTOGENERATED FILE with tools/syz-declextract.

VerSetConditionMask(ConditionMask int64, TypeMask int32, Condition int8)
GetEnvironmentStrings()
Expand Down
21 changes: 21 additions & 0 deletions tools/check-copyright.sh
@@ -0,0 +1,21 @@
#!/bin/bash
# Copyright 2020 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

FILES=0
FAILED=""
for F in $(find -name "*.go" -o -name "*.sh" -o \( -path "./sys/*/*.txt" \) | egrep -v "/vendor/|/gen/"); do
((FILES+=1))
cat $F | tr '\n' '_' | egrep "(//|#) Copyright 20[0-9]{2}(/20[0-9]{2})? syzkaller project authors\. All rights reserved\._(//|#) Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file\." >/dev/null
if [ $? -eq 0 ]; then continue; fi
# Ignore auto-generated files.
egrep "(//|#) AUTOGENERATED FILE|(WARNING: This file is machine generated)" $F >/dev/null
if [ $? -eq 0 ]; then continue; fi
# Ignore untracked files.
git ls-files --error-unmatch $F >/dev/null 2>&1
if [ $? -ne 0 ]; then continue; fi
echo "$F: does not have standard copyright statement"
FAILED="1"
done
if [ "$FAILED" != "" ]; then exit 1; fi
echo "$FILES files checked for copyright statement"
3 changes: 1 addition & 2 deletions tools/create-openbsd-gce-ci.sh
@@ -1,8 +1,7 @@
#!/bin/bash

# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in
# the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# Produces GCE image of syz-ci running on OpenBSD.

Expand Down
3 changes: 1 addition & 2 deletions tools/create-openbsd-vmm-worker.sh
@@ -1,8 +1,7 @@
#!/bin/bash

# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in
# the LICENSE file.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# Produces a very minimal image for running syzkaller fuzzers running on OpenBSD.

Expand Down
3 changes: 3 additions & 0 deletions tools/syz-trace2syz/proggen/call_selector.go
@@ -1,3 +1,6 @@
// Copyright 2018 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package proggen

import (
Expand Down

0 comments on commit 135c18a

Please sign in to comment.