Merge bitcoin/bitcoin#36967: lint: check copyright headers
What changed, and why it matters
This commit is a housekeeping change for Bitcoin Core. It adds a new automated linter that checks whether source files have the correct copyright header, and it updates or adds those headers across 27 files. There is no change to how Bitcoin works, no bug fix, and no security-relevant code change.
No security action needed. Treat as normal project hygiene/CI improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit introduces a Rust-based lint (lint_copyright_doc in test/lint/test_runner/src/lint_docs.rs) that scans .py, .cpp, .h, .sh, and *.rs files for a standard Bitcoin Core copyright header. It also adds missing headers, normalizes existing headers to ‘The Bitcoin Core developers’, and updates license URLs from http://www.opensource.org/licenses/mit-license.php to https://opensource.org/license/mit. The diff is purely metadata/header and tooling; no executable logic is modified.
Changed components
test/lint/test_runner/src/lint_docs.rstest/lint/test_runner/src/main.rs27 source/script files with updated copyright headersInspect captured patch +138 / −22
### ci/test/00_setup_env_riscv_bare_cross.sh
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#
-# Copyright (c) Bitcoin Core developers
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit.
export LC_ALL=C.UTF-8
### contrib/asmap/asmap-tool.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Copyright (c) 2022 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
import argparse
import sys
### contrib/asmap/asmap.py
@@ -1,6 +1,8 @@
+#!/usr/bin/env python3
# Copyright (c) 2022 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""
This module provides the ASNEntry and ASMap classes.
### contrib/devtools/bitcoin-tidy/bitcoin-tidy.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 Bitcoin Developers
+// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
### contrib/devtools/bitcoin-tidy/example_nontrivial-threadlocal.cpp
@@ -1,2 +1,6 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit.
+
#include <string>
thread_local std::string foo;
### contrib/devtools/bitcoin-tidy/nontrivial-threadlocal.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 Bitcoin Developers
+// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
### contrib/devtools/bitcoin-tidy/nontrivial-threadlocal.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2023 Bitcoin Developers
+// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
### contrib/devtools/check-deps.sh
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
+# Copyright (c) The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit.
export LC_ALL=C.UTF-8
set -Eeuo pipefail
### contrib/devtools/headerssync-params.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Copyright (c) 2022 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Script to find the optimal parameters for the headerssync module through simulation."""
### contrib/guix/symbol-check.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Copyright (c) 2014 Wladimir J. van der Laan
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
'''
A script to check that release executables only contain certain symbols
and are only linked against allowed libraries.
### contrib/macdeploy/gen-sdk.py
@@ -1,4 +1,8 @@
#!/usr/bin/env python3
+# Copyright (c) The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit.
+
import argparse
import plistlib
import pathlib
### contrib/verify-binaries/test.py
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
+# Copyright (c) The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit.
import json
import os
### share/qt/translate.cmake
@@ -46,7 +46,11 @@ function(extract_strings output)
endif()
endforeach()
- set(content [[// Automatically generated by translate.cmake
+ set(content [[// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit.
+
+// Automatically generated by translate.cmake
#include <QtGlobal>
### src/cuckoocache.h
@@ -1,6 +1,7 @@
// Copyright (c) 2016 Jeremy Rubin
+// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or https://opensource.org/license/mit.
#ifndef BITCOIN_CUCKOOCACHE_H
#define BITCOIN_CUCKOOCACHE_H
### src/qt/bitcoinstrings.cpp
@@ -1,3 +1,7 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit.
+
// Automatically generated by translate.cmake
#include <QtGlobal>
### src/test/torcontrol_tests.cpp
@@ -1,7 +1,7 @@
// Copyright (c) 2017 The Zcash developers
+// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-//
+// file COPYING or https://opensource.org/license/mit.
#include <boost/test/unit_test.hpp>
### src/univalue/include/univalue_utffilter.h
@@ -1,6 +1,8 @@
// Copyright 2016 Wladimir J. van der Laan
+// Copyright (c) The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or https://opensource.org/licenses/mit-license.php.
+// file COPYING or https://opensource.org/license/mit.
+
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
### src/wallet/migration.cpp
@@ -1,3 +1,7 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit.
+
#include <key_io.h>
#include <wallet/context.h>
### src/wallet/migration.h
@@ -1,3 +1,7 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit.
+
#ifndef BITCOIN_WALLET_MIGRATION_H
#define BITCOIN_WALLET_MIGRATION_H
### test/functional/feature_utxo_abort_on_error.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
-# Distributed under the MIT software license.
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or https://opensource.org/license/mit.
"""
Ensures that UTXO unserialization errors abort the node, and does not
### test/functional/test_framework/crypto/muhash.py
@@ -1,6 +1,7 @@
# Copyright (c) 2020 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Native Python MuHash3072 implementation."""
import hashlib
### test/functional/test_framework/crypto/ripemd160.py
@@ -1,6 +1,7 @@
# Copyright (c) 2021 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Test-only pure Python RIPEMD160 implementation."""
import unittest
### test/functional/test_framework/descriptors.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Copyright (c) 2019 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Utility functions related to output descriptors"""
import re
### test/functional/test_framework/key.py
@@ -1,6 +1,7 @@
# Copyright (c) 2019-2020 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Test-only secp256k1 elliptic curve protocols implementation
WARNING: This code is slow, uses bad randomness, does not properly protect
### test/functional/test_framework/segwit_addr.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Copyright (c) 2017 Pieter Wuille
+# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+# file COPYING or https://opensource.org/license/mit/.
"""Reference implementation for Bech32/Bech32m and segwit addresses."""
import unittest
from enum import Enum
### test/lint/test_runner/src/lint_docs.rs
@@ -6,7 +6,74 @@ use std::fs;
use std::io::ErrorKind;
use std::process::{Command, Stdio};
-use crate::util::{check_output, get_subtrees, git, LintResult};
+use crate::util::{check_output, get_pathspecs_default_excludes, get_subtrees, git, LintResult};
+
+fn has_copyright_header(file: &str) -> bool {
+ let text = fs::read_to_string(file).expect("File should be readable");
+ let mut lines = text
+ .lines()
+ .map(|line| line.trim_start_matches("// ").trim_start_matches("# "));
+
+ lines
+ .find(|line| line.starts_with("Copyright") && line.ends_with("The Bitcoin Core developers"))
+ .is_some()
+ && lines
+ .find(|line| line.starts_with("Distributed under the MIT software license"))
+ .is_some()
+ && lines
+ .next()
+ .is_some_and(|line| line.starts_with("file COPYING or http"))
+}
+
+pub fn lint_copyright_doc() -> LintResult {
+ let files = check_output(
+ git()
+ .args([
+ "ls-files",
+ "--full-name",
+ "--",
+ "*.py",
+ "*.cpp",
+ "*.h",
+ "*.sh",
+ "*.rs",
+ ])
+ .args(get_pathspecs_default_excludes())
+ .args([
+ // External copyright.
+ ":(exclude)contrib/devtools/clang-format-diff.py",
+ ":(exclude)src/bench/nanobench.h",
+ ":(exclude)src/test/fuzz/FuzzedDataProvider.h",
+ ":(exclude)src/tinyformat.h",
+ ":(exclude)src/univalue/lib/univalue_write.cpp",
+ ":(exclude)src/util/subprocess.h",
+ ":(exclude)test/functional/test_framework/authproxy.py",
+ // Empty Python package marker files.
+ ":(exclude,glob)**/__init__.py",
+ ]),
+ )
+ .expect("Git should be callable");
+
+ let missing_headers: Vec<_> = files
+ .lines()
+ .filter(|file| !has_copyright_header(file))
+ .map(|file| format!("No copyright header found in {file}"))
+ .collect();
+
+ if !missing_headers.is_empty() {
+ println!("{}", missing_headers.join("\n"));
+ Err(r#"
+Add the missing copyright headers, or exclude the above paths if not applicable.
+
+Please also see the copyright section from
+https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#copyright
+ "#
+ .trim()
+ .to_string())
+ } else {
+ Ok(())
+ }
+}
pub fn lint_doc_release_note_snippets() -> LintResult {
let non_release_notes = check_output(git().args([
### test/lint/test_runner/src/main.rs
@@ -17,7 +17,7 @@ use lint_cpp::{
lint_assert_falsy, lint_boost_assert, lint_includes_build_config, lint_remove_all,
lint_rpc_assert, lint_std_filesystem,
};
-use lint_docs::{lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
+use lint_docs::{lint_copyright_doc, lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
use lint_py::{lint_py_lint, lint_rmtree};
use lint_repo_hygiene::{lint_scripted_diff, lint_subtree};
use lint_text_format::{
@@ -33,6 +33,11 @@ struct Linter {
fn get_linter_list() -> Vec<&'static Linter> {
vec![
+ &Linter {
+ description: "Check that files contain the copyright header.",
+ name: "copyright_doc",
+ lint_fn: lint_copyright_doc,
+ },
&Linter {
description: "Check that all command line arguments are documented.",
name: "doc",Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.