CI: add whitespace checker

Fix issues detected.

Also:

- One of the `.vc` files used LF EOLs, while the other didn't.
  Make that one also use LF EOLs, as this is apparently supported by
  `nmake`.

- Drop `.dsw` and `.btn` types from `.gitattributes`.
  The repository doesn't use them.

- Sync section order with the rest of files in
  `tests/certs/EdelCurlRoot-ca.prm`.

- Indent/align `.prm` and `.pem` files.

- Delete dummy `[something]` section from `.prm` and `.pem` files.

Mental note:
MSVC `.sln` files seem to accept spaces for indentation and also support
LF line-endings. I cannot test this and I don't know what's more
convenient when updating them, so left them as-is, with specific
exclusions.

Closes #14031
This commit is contained in:
Viktor Szakats 2024-06-27 02:38:38 +02:00
parent 8f67e81735
commit 1ccdad64ef
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
42 changed files with 1174 additions and 1037 deletions

4
.gitattributes vendored
View File

@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: curl
*.dsw -crlf
buildconf eol=lf
configure.ac eol=lf
*.m4 eol=lf
@ -11,8 +10,7 @@ configure.ac eol=lf
*.sh eol=lf
*.[ch] whitespace=tab-in-indent
# Batch files (bat,btm,cmd) must be run with CRLF line endings.
# Batch files (bat,cmd) must be run with CRLF line endings.
# Refer to https://github.com/curl/curl/pull/6442
*.bat text eol=crlf
*.btm text eol=crlf
*.cmd text eol=crlf

153
.github/scripts/spacecheck.pl vendored Executable file
View File

@ -0,0 +1,153 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Viktor Szakats
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
use strict;
use warnings;
my @tabs = (
"^m4/zz40-xc-ovr.m4",
"Makefile\\.[a-z]+\$",
"/mkfile",
"\\.(bat|cmd|sln|vc)\$",
"^tests/certs/.+\\.der\$",
"^tests/data/test",
);
my @mixed_eol = (
"^tests/certs/.+\\.(crt|der)\$",
"^tests/certs/Server-localhost0h-sv.pem",
"^tests/data/test",
);
my @need_crlf = (
"\\.(bat|sln)\$",
"^winbuild/.+\\.(cmd|md)\$",
);
my @space_at_eol = (
"^tests/.+\\.(cacert|crt|pem)\$",
"^tests/data/test",
);
my @eol_at_eof = (
"^tests/certs/.+\\.der\$",
);
sub fn_match {
my ($filename, @masklist) = @_;
foreach my $mask (@masklist) {
if ($filename =~ $mask) {
return 1;
}
}
return 0;
}
sub eol_detect {
my ($content) = @_;
my $cr = () = $content =~ /\r/g;
my $lf = () = $content =~ /\n/g;
if ($cr > 0 && $lf == 0) {
return "cr"
}
elsif ($cr == 0 && $lf > 0) {
return "lf"
}
elsif ($cr == 0 && $lf == 0) {
return "bin"
}
elsif ($cr == $lf) {
return "crlf"
}
return ""
}
my $issues = 0;
open my $git_ls_files, '-|', 'git ls-files' or die "Failed running git ls-files: $!";
while (my $filename = <$git_ls_files>) {
chomp $filename;
open my $fh, '<', $filename or die "Cannot open '$filename': $!";
my $content = do { local $/; <$fh> };
close $fh;
my @err = ();
if (!fn_match($filename, @tabs) &&
$content =~ /\t/) {
push @err, "content: has tab";
}
my $eol = eol_detect($content);
if ($eol eq "" &&
!fn_match($filename, @mixed_eol)) {
push @err, "content: has mixed EOL types";
}
if ($eol ne "crlf" &&
fn_match($filename, @need_crlf)) {
push @err, "content: must use CRLF EOL for this file type";
}
if ($eol ne "lf" && $content ne "" &&
!fn_match($filename, @need_crlf) &&
!fn_match($filename, @mixed_eol)) {
push @err, "content: must use LF EOL for this file type";
}
if (!fn_match($filename, @space_at_eol) &&
$content =~ /[ \t]\n/) {
push @err, "content: has line-ending whitespace";
}
if ($content ne "" &&
!fn_match($filename, @eol_at_eof) &&
$content !~ /\n\z/) {
push @err, "content: has no EOL at EOF";
}
if ($content =~ /\n\n\z/ ||
$content =~ /\r\n\r\n\z/) {
push @err, "content: has multiple EOL at EOF";
}
if (@err) {
$issues++;
foreach my $err (@err) {
print "$filename: $err\n";
}
}
}
close $git_ls_files;
if ($issues) {
exit 1;
}

28
.github/workflows/spacecheck.yml vendored Normal file
View File

@ -0,0 +1,28 @@
# Copyright (C) Viktor Szakats
#
# SPDX-License-Identifier: curl
name: spacecheck
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
spacecheck:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: 'spacecheck'
run: .github/scripts/spacecheck.pl

View File

@ -1,16 +1,5 @@
extensions = x509v3
[ req ]
default_bits = 2048
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name"
countryName_value = NN
organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = Northern Nowhere Trust Anchor
[ x509v3 ]
basicConstraints = critical,CA:true
keyUsage = critical,keyCertSign,cRLSign
@ -28,3 +17,17 @@ caIssuers;URI.0 = http://test.curl.se/ca/EdelCurlRoot.cer
[ crl_info ]
URI.0 = http://test.curl.se/ca/EdelCurlRoot.crl
[ req ]
default_bits = 2048
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name"
countryName_value = NN
organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = Northern Nowhere Trust Anchor

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost,DNS:localhost1,DNS:localhost2
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -32,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqFG49ghwozY+A
r1DtF5dt5qhhPqyorBPOmespLElz+RJANcR5hA2esCjEn2TjwW0tcRFdSxRhIEsY

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost,DNS:localhost1,DNS:localhost2
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -32,8 +33,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost1,DNS:localhost2,DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDIhP5pZDPD3LV0
iseyu9lp4qmVbV+3JeaCACv1UyHnKK5mtjj9FbGRiFIxKbtz4uCZYpVENVHXVMjS

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost1,DNS:localhost2,DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,8 +33,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDGuAQ91voxoNf3
6YhLWl5vb9v0yUt+bCrPNHsquhpxrX94bPceygfQKQNJ5GOGTPZnP70yacu4FecO

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,8 +33,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost.nn
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCjmuQP4L2TqVqn
Xq2FXtbgmLTpIuBikMPZVzcWXVc9aMrizy9GZxoMrw6JhgEG39bJgBUKQ4VAP9ru

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost.nn
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,8 +33,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost.nn
[something]
# The key
# the certificate
# some dhparam

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
#subjectAltName = DNS:localhost\0h
subjectAltName = DER:30:0d:82:0b:6c:6f:63:61:6c:68:6f:73:74:00:68
@ -25,6 +26,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -32,11 +34,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDfKZNYgh2iuAcq
so+TDt8VSXIGkxlKLcW9VpJa2vTTmgEc7kdXDp7Y1w3Ezkui8PwH7JHplQj06V3y

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
#subjectAltName = DNS:localhost\0h
subjectAltName = DER:30:0d:82:0b:6c:6f:63:61:6c:68:6f:73:74:00:68
@ -25,6 +26,7 @@ default_bits = 1024
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -32,8 +34,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 12048
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCrCrAD0Hb+Xs4V
3mHV45FvfNa7yiaOeL4mNdGmWfHVPFU+CSzsoNSvDjxaorWweFGVYoCAcchOn1lZ

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 12048
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,8 +33,3 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam

View File

@ -51,4 +51,3 @@ Accept: */*
</protocol>
</verify>
</testcase>

View File

@ -45,4 +45,3 @@ disable
</valgrind>
</verify>
</testcase>

View File

@ -172,5 +172,3 @@ class TestShutdown:
# check connection cache closings
shutdowns = [l for l in r.trace_lines if re.match(r'.*CCACHE\] shutdown #\d+, done=1', l)]
assert len(shutdowns) == 1, f'{shutdowns}'

View File

@ -1,4 +1,5 @@
extensions = x509v3
[ x509v3 ]
subjectAltName = DNS:localhost
keyUsage = keyEncipherment,digitalSignature,keyAgreement
@ -24,6 +25,7 @@ default_bits = 12048
distinguished_name = req_DN
default_md = sha256
string_mask = utf8only
[ req_DN ]
countryName = "Country Name is Northern Nowhere"
countryName_value = NN
@ -31,11 +33,6 @@ organizationName = "Organization Name"
organizationName_value = Edel Curl Arctic Illudium Research Cloud
commonName = "Common Name"
commonName_value = localhost
[something]
# The key
# the certificate
# some dhparam
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCrCrAD0Hb+Xs4V
3mHV45FvfNa7yiaOeL4mNdGmWfHVPFU+CSzsoNSvDjxaorWweFGVYoCAcchOn1lZ