mirror of
https://codeberg.org/scip/Config-General.git
synced 2026-11-22 15:48:59 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c15f995566 | |||
| 6ff6043dd5 | |||
| 7afdb41b71 | |||
| bfc7b838f5 | |||
| 0a480f2632 | |||
| f7c91dff2b | |||
| fe00738811 | |||
| abad53b84e | |||
| 1c27e5e8ef |
@@ -1,54 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This is my own simple codeberg generic releaser. It takes to
|
|
||||||
# binaries to be uploaded as arguments and takes every other args from
|
|
||||||
# env. Works on tags or normal commits (push), tags must start with v.
|
|
||||||
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo $*
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if test -z "$DEPLOY_TOKEN"; then
|
|
||||||
die "token DEPLOY_TOKEN not set"
|
|
||||||
fi
|
|
||||||
|
|
||||||
git fetch --all
|
|
||||||
|
|
||||||
# determine current tag or commit hash
|
|
||||||
version="$CI_COMMIT_TAG"
|
|
||||||
previous=""
|
|
||||||
log=""
|
|
||||||
if test -z "$version"; then
|
|
||||||
version="${CI_COMMIT_SHA:0:6}"
|
|
||||||
log=$(git log -1 --oneline)
|
|
||||||
else
|
|
||||||
previous=$(git tag -l | grep -E "^v" | tac | grep -A1 "$version" | tail -1)
|
|
||||||
log=$(git log -1 --oneline "${previous}..${version}" | sed 's|^|- |g')
|
|
||||||
fi
|
|
||||||
|
|
||||||
# release body
|
|
||||||
printf "# Changes\n\n %s\n" "$log" > body.txt
|
|
||||||
|
|
||||||
# create the release
|
|
||||||
https --ignore-stdin --check-status -b -A bearer -a "$DEPLOY_TOKEN" POST \
|
|
||||||
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases" \
|
|
||||||
tag_name="$version" name="Release $version" body=@body.txt > release.json
|
|
||||||
|
|
||||||
# we need the id to upload files
|
|
||||||
ID=$(jq -r .id < release.json)
|
|
||||||
|
|
||||||
if test -z "$ID"; then
|
|
||||||
cat release.json
|
|
||||||
die "failed to create release"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# actually upload
|
|
||||||
for file in "$@"; do
|
|
||||||
https --ignore-stdin --check-status -A bearer -a "$DEPLOY_TOKEN" -f POST \
|
|
||||||
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/$ID/assets" \
|
|
||||||
"name=${file}" "attachment@${file}"
|
|
||||||
done
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# build release
|
|
||||||
|
|
||||||
steps:
|
|
||||||
compile:
|
|
||||||
when:
|
|
||||||
event: [tag]
|
|
||||||
image: perl:5.43.5-slim-bookworm
|
|
||||||
commands:
|
|
||||||
- perl Makefile.PL
|
|
||||||
- make
|
|
||||||
- make dist
|
|
||||||
|
|
||||||
release:
|
|
||||||
image: alpine:latest
|
|
||||||
when:
|
|
||||||
event: [tag]
|
|
||||||
environment:
|
|
||||||
DEPLOY_TOKEN:
|
|
||||||
from_secret: DEPLOY_TOKEN
|
|
||||||
commands:
|
|
||||||
- apk update
|
|
||||||
- apk add --no-cache bash httpie jq git
|
|
||||||
- .woodpecker/release.sh Config-General-$CI_COMMIT_TAG.tar.gz
|
|
||||||
77
General.pm
77
General.pm
@@ -5,7 +5,7 @@
|
|||||||
# config values from a given file and
|
# config values from a given file and
|
||||||
# return it as hash structure
|
# return it as hash structure
|
||||||
#
|
#
|
||||||
# Copyright (c) 2000-2026 Thomas Linden <tlinden |AT| cpan.org>.
|
# Copyright (c) 2000-2025 Thomas Linden <tlinden |AT| cpan.org>.
|
||||||
# All Rights Reserved. Std. disclaimer applies.
|
# All Rights Reserved. Std. disclaimer applies.
|
||||||
# Licensed under the Artistic License 2.0.
|
# Licensed under the Artistic License 2.0.
|
||||||
#
|
#
|
||||||
@@ -20,7 +20,7 @@ use IO::File;
|
|||||||
use FileHandle;
|
use FileHandle;
|
||||||
use File::Spec::Functions qw(splitpath file_name_is_absolute catfile catpath);
|
use File::Spec::Functions qw(splitpath file_name_is_absolute catfile catpath);
|
||||||
use File::Glob qw/:glob/;
|
use File::Glob qw/:glob/;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
# on debian with perl > 5.8.4 croak() doesn't work anymore without this.
|
# on debian with perl > 5.8.4 croak() doesn't work anymore without this.
|
||||||
# There is some require statement which dies 'cause it can't find Carp::Heavy,
|
# There is some require statement which dies 'cause it can't find Carp::Heavy,
|
||||||
@@ -32,7 +32,7 @@ use Carp::Heavy;
|
|||||||
use Carp;
|
use Carp;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
|
|
||||||
$Config::General::VERSION = "2.68";
|
$Config::General::VERSION = "2.67";
|
||||||
|
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
our @EXPORT_OK = qw(ParseConfig SaveConfig SaveConfigString);
|
our @EXPORT_OK = qw(ParseConfig SaveConfig SaveConfigString);
|
||||||
@@ -286,10 +286,6 @@ sub _prepare {
|
|||||||
$self->{ConfigFile} = delete $conf{-file};
|
$self->{ConfigFile} = delete $conf{-file};
|
||||||
}
|
}
|
||||||
if (exists $conf{-hash}) {
|
if (exists $conf{-hash}) {
|
||||||
if (! $self->_validate_input_hash($conf{-hash})) {
|
|
||||||
croak "Config::General: supplied -hash hash contains invalid keys or values!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{ConfigHash} = delete $conf{-hash};
|
$self->{ConfigHash} = delete $conf{-hash};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,10 +294,6 @@ sub _prepare {
|
|||||||
$self->{ConfigFile} = delete $conf{-ConfigFile};
|
$self->{ConfigFile} = delete $conf{-ConfigFile};
|
||||||
}
|
}
|
||||||
if (exists $conf{-ConfigHash}) {
|
if (exists $conf{-ConfigHash}) {
|
||||||
if (! $self->_validate_input_hash($conf{-ConfigHash})) {
|
|
||||||
croak "Config::General: supplied -ConfigHash hash contains invalid keys or values!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{ConfigHash} = delete $conf{-ConfigHash};
|
$self->{ConfigHash} = delete $conf{-ConfigHash};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,10 +340,6 @@ sub _prepare {
|
|||||||
if (exists $conf{-DefaultConfig}) {
|
if (exists $conf{-DefaultConfig}) {
|
||||||
if ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq 'HASH') {
|
if ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq 'HASH') {
|
||||||
# copy the hashref so that it is not being modified by subsequent calls, fixes bug#142095
|
# copy the hashref so that it is not being modified by subsequent calls, fixes bug#142095
|
||||||
if (! $self->_validate_input_hash($conf{-DefaultConfig})) {
|
|
||||||
croak "Config::General: supplied -DefaultConfig hash contains invalid keys or values!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{DefaultConfig} = $self->_copy($conf{-DefaultConfig});
|
$self->{DefaultConfig} = $self->_copy($conf{-DefaultConfig});
|
||||||
}
|
}
|
||||||
elsif ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq q()) {
|
elsif ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq q()) {
|
||||||
@@ -1506,61 +1494,6 @@ sub _hashref {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _validate_input_hash {
|
|
||||||
#
|
|
||||||
# Checks if a given input hash contains invalid keys or values.
|
|
||||||
# Fixes https://codeberg.org/scip/Config-General/issues/9.
|
|
||||||
#
|
|
||||||
my($this, $hash) = @_;
|
|
||||||
|
|
||||||
if (ref($hash) eq '') {
|
|
||||||
return $this->_validate_input_hash_value($hash);
|
|
||||||
}
|
|
||||||
elsif (ref($hash) eq 'ARRAY') {
|
|
||||||
foreach my $sub (@{$hash}) {
|
|
||||||
return $this->_validate_input_hash($sub);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $key (keys %{$hash}) {
|
|
||||||
if (! $this->_validate_input_hash_value($key)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ref($hash->{$key}) eq 'ARRAY') {
|
|
||||||
foreach my $sub (@{$hash->{$key}}) {
|
|
||||||
if (! $this->_validate_input_hash($sub)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif(ref($hash->{$key}) eq 'HASH') {
|
|
||||||
if (! $this->_validate_input_hash($hash->{$key})) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (! $this->_validate_input_hash_value($hash->{$key})) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _validate_input_hash_value {
|
|
||||||
#
|
|
||||||
# Checks a given key or value against a deny regex
|
|
||||||
my ($this, $value) = @_;
|
|
||||||
|
|
||||||
if ($value =~ /(<<|>>|\*\/|\/\*|#)/) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Procedural interface
|
# Procedural interface
|
||||||
@@ -2926,7 +2859,7 @@ I recommend you to read the following documents, which are supplied with Perl:
|
|||||||
|
|
||||||
=head1 LICENSE AND COPYRIGHT
|
=head1 LICENSE AND COPYRIGHT
|
||||||
|
|
||||||
Copyright (c) 2000-2026 Thomas Linden
|
Copyright (c) 2000-2025 Thomas Linden
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the same terms of the Artistic License 2.0.
|
modify it under the same terms of the Artistic License 2.0.
|
||||||
@@ -2955,7 +2888,7 @@ Thomas Linden <tlinden |AT| cpan.org>
|
|||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
2.68
|
2.67
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Makefile.PL - build file for Config::General
|
# Makefile.PL - build file for Config::General
|
||||||
#
|
#
|
||||||
# Copyright (c) 2000-2026 Thomas Linden <tom@daemon.de>.
|
# Copyright (c) 2000-2022 Thomas Linden <tom@daemon.de>.
|
||||||
# All Rights Reserved. Std. disclaimer applies.
|
# All Rights Reserved. Std. disclaimer applies.
|
||||||
# Licensed under the Artistic License 2.0.
|
# Licensed under the Artistic License 2.0.
|
||||||
#
|
#
|
||||||
|
|||||||
65
t/run.t
65
t/run.t
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Test::More tests => 93;
|
use Test::More tests => 79;
|
||||||
#use Test::More qw(no_plan);
|
#use Test::More qw(no_plan);
|
||||||
|
|
||||||
# ahem, we deliver the test code with a local copy of
|
# ahem, we deliver the test code with a local copy of
|
||||||
@@ -801,66 +801,3 @@ my $conf59 = Config::General->new(
|
|||||||
-AlwaysQuoteOutput => 1);
|
-AlwaysQuoteOutput => 1);
|
||||||
my $got59 = $conf59->save_string();
|
my $got59 = $conf59->save_string();
|
||||||
is_deeply \$expected59, \$got59, "quotes";
|
is_deeply \$expected59, \$got59, "quotes";
|
||||||
|
|
||||||
|
|
||||||
# test for CVE-2026-129820 and CVE-2026-129821 fixes
|
|
||||||
my $cvedefaults = [
|
|
||||||
{
|
|
||||||
"*/ foo" => 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo */" => 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo <<EOF foo" => 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<<include nix>>" => 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"*/ foo" => "hans",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo # 1" => "nix",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo" => "*/ hier",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo" => "hier */",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo" => "<<EOF hier",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"foo" => "<<include hier>>",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"users" => {
|
|
||||||
"hans" => "*/ maddock",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"users" => {
|
|
||||||
"hans" => "maddock /*",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"users" => {
|
|
||||||
"hans" => "<<EOF maddock",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"list" => [
|
|
||||||
"ok",
|
|
||||||
"*/ foo",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
foreach my $default (@{$cvedefaults}) {
|
|
||||||
eval {
|
|
||||||
my $conf60 = Config::General->new(-ConfigHash => $default) or die "$@";
|
|
||||||
};
|
|
||||||
|
|
||||||
ok($@, "cve check failed: " . Dumper($default));
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user