Skip to content

Commit c58e3ba

Browse files
Merge pull request #1 from Black-HOST/main
Pushing CSF to the upstream
2 parents c15ade0 + a202958 commit c58e3ba

383 files changed

Lines changed: 93460 additions & 831 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Summary
2+
3+
<!-- What does this PR change and why? -->
4+
5+
6+
## Related Issues
7+
8+
<!-- Link issues (e.g. Closes #123, Fixes #456) -->
9+
10+
11+
## Type of Change
12+
13+
- [ ] Bug fix
14+
- [ ] New feature
15+
- [ ] Refactor
16+
- [ ] Docs / comments
17+
- [ ] CI / tooling
18+
- [ ] Security hardening
19+
20+
21+
## Affected Areas
22+
23+
- [ ] Installer scripts (`install*.sh`)
24+
- [ ] Runtime scripts (`csf.pl`, `lfd.pl`, etc.)
25+
- [ ] Config defaults (`conf/*`)
26+
- [ ] Templates (`tpl/*`)
27+
- [ ] UI assets (`conf/ui/*`)
28+
- [ ] Packaging / release
29+
30+
31+
## Testing
32+
33+
<!-- Describe what you tested and where -->
34+
35+
Environment(s):
36+
- [ ] AlmaLinux
37+
- [ ] Rocky Linux
38+
- [ ] Ubuntu / Debian
39+
- [ ] Other: __________
40+
41+
Validation performed:
42+
- [ ] Fresh install works
43+
- [ ] Upgrade path works
44+
- [ ] Paths/files copied to expected destinations
45+
- [ ] No regressions in existing behavior
46+
- [ ] CI checks pass
47+
48+
Test notes:
49+
50+
51+
## Checklist
52+
53+
- [ ] I reviewed changed paths and file references
54+
- [ ] I updated docs/comments if needed
55+
- [ ] I kept changes focused and minimal
56+
- [ ] I verified shell syntax for modified scripts
57+
- [ ] I confirmed no secrets or private data were added

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CSF Tag & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
paths:
9+
- 'version.txt' # make new release only on version change
10+
11+
workflow_dispatch: {}
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Get version
25+
run: |
26+
VERSION=$(cat version.txt | xargs)
27+
echo "TAG=v$VERSION" >> $GITHUB_ENV
28+
29+
- name: Build release archive
30+
run: git archive --format=tar.gz --prefix="csf/" -o "csf.tgz" HEAD
31+
32+
- name: Do the release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: gh release create "$TAG" ./csf.tgz --repo="$GITHUB_REPOSITORY" --title="$TAG" --generate-notes
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: TEST - Remote Installation
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
paths:
7+
- '**/install*'
8+
9+
pull_request:
10+
branches: [ "**" ]
11+
paths:
12+
- '**/install*'
13+
14+
workflow_dispatch: {}
15+
16+
jobs:
17+
remote-install:
18+
name: Install on ${{ matrix.os-name }}
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
# Debian
25+
- os-name: "Debian 12"
26+
container: "debian:12"
27+
setup-cmd: "apt-get update && apt-get install -y curl"
28+
- os-name: "Debian 13 (Trixie)"
29+
container: "debian:trixie-slim"
30+
setup-cmd: "apt-get update && apt-get install -y curl"
31+
32+
# Ubuntu
33+
- os-name: "Ubuntu 22.04"
34+
container: "ubuntu:22.04"
35+
setup-cmd: "apt-get update && apt-get install -y curl"
36+
- os-name: "Ubuntu 24.04"
37+
container: "ubuntu:24.04"
38+
setup-cmd: "apt-get update && apt-get install -y curl"
39+
40+
# AlmaLinux
41+
- os-name: "AlmaLinux 8"
42+
container: "almalinux:8"
43+
setup-cmd: "dnf install -y epel-release curl"
44+
- os-name: "AlmaLinux 9"
45+
container: "almalinux:9"
46+
setup-cmd: "dnf install -y epel-release"
47+
- os-name: "AlmaLinux 10"
48+
container: "almalinux:10"
49+
setup-cmd: "dnf install -y epel-release"
50+
51+
container:
52+
image: ${{ matrix.container }}
53+
options: --privileged
54+
55+
steps:
56+
- name: Install minimal dependencies
57+
if: ${{ matrix.setup-cmd }}
58+
run: ${{ matrix.setup-cmd }}
59+
60+
- name: Run Live Installer
61+
shell: bash
62+
run: |
63+
bash <(curl -sL https://csf.black.host)
64+
65+
- name: Verify Configuration Exists
66+
run: |
67+
if [ -f "/etc/csf/csf.conf" ]; then
68+
echo "csf.conf found"
69+
else
70+
echo "csf.conf NOT found"
71+
exit 1
72+
fi
73+
74+
- name: Verify Binary Exists
75+
run: |
76+
if [ -f "/usr/sbin/csf" ]; then
77+
echo "csf binary found"
78+
else
79+
echo "csf binary NOT found"
80+
exit 1
81+
fi
82+
83+
- name: Check Version
84+
run: |
85+
# installer.sh might not put csftest.pl in path, but it should be in /usr/local/csf/bin
86+
if [ -f "/usr/local/csf/bin/csftest.pl" ]; then
87+
perl /usr/local/csf/bin/csftest.pl || true
88+
fi
89+
csf -v || true

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing to CSF
2+
3+
This repository is a community-maintained fork focused on keeping CSF secure, stable, and compatible with modern Linux systems.
4+
5+
## Ground Rules
6+
7+
- Keep changes focused and minimal.
8+
- Prefer backward-compatible behavior unless a breaking change is necessary and agreed by the community.
9+
- For security issues, **do not open a public issue**. See [SECURITY.md](SECURITY.md).
10+
11+
## Development Workflow
12+
13+
1. Fork the repository and create a feature branch from `main`.
14+
2. Make your changes in small, reviewable commits.
15+
3. Open a Pull Request with clear context:
16+
- what changed
17+
- why it changed
18+
- how it was tested
19+
20+
## Testing
21+
22+
Before opening a PR, validate as much as possible:
23+
24+
- syntax and path sanity of changed shell scripts
25+
- installer flow on at least one Debian/Ubuntu and one RHEL/Alma-based environment
26+
- CSF install output and basic checks (`csf -v`, `csftest.pl`)
27+
28+
CI exists, but local/reproducible validation is still strongly encouraged.
29+
30+
## Pull Request Checklist
31+
32+
- [ ] Change is scoped and documented
33+
- [ ] Paths updated consistently across installer scripts
34+
- [ ] No secrets, tokens, or private material committed
35+
- [ ] Security-sensitive behavior explained
36+
- [ ] Testing notes included in PR description
37+
38+
## Coding Style
39+
40+
- Keep shell scripts POSIX-friendly where practical
41+
- Use consistent formatting with surrounding code
42+
- Avoid unrelated refactors in the same PR
43+
44+
## License
45+
46+
By contributing, you agree that your contributions are licensed under the same license as this project (GPLv3).
47+
48+
Thanks for helping improve CSF ❤️

ConfigServer/AbuseIP.pm

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
###############################################################################
2+
# Copyright (C) 2006-2025 Jonathan Michaelson
3+
#
4+
# https://github.com/waytotheweb/scripts
5+
#
6+
# This program is free software; you can redistribute it and/or modify it under
7+
# the terms of the GNU General Public License as published by the Free Software
8+
# Foundation; either version 3 of the License, or (at your option) any later
9+
# version.
10+
#
11+
# This program is distributed in the hope that it will be useful, but WITHOUT
12+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+
# details.
15+
#
16+
# You should have received a copy of the GNU General Public License along with
17+
# this program; if not, see <https://www.gnu.org/licenses>.
18+
###############################################################################
19+
## no critic (RequireUseWarnings, ProhibitExplicitReturnUndef, ProhibitMixedBooleanOperators, RequireBriefOpen)
20+
# start main
21+
package ConfigServer::AbuseIP;
22+
23+
use strict;
24+
use lib '/usr/local/csf/lib';
25+
use Carp;
26+
use IPC::Open3;
27+
use Net::IP;
28+
use ConfigServer::Config;
29+
use ConfigServer::CheckIP qw(checkip);
30+
31+
use Exporter qw(import);
32+
our $VERSION = 1.03;
33+
our @ISA = qw(Exporter);
34+
our @EXPORT_OK = qw(abuseip);
35+
36+
my $abusemsg = 'Abuse Contact for [ip]: [[contact]]
37+
38+
The Abuse Contact of this report was provided by the Abuse Contact DB by abusix.com. abusix.com does not maintain the content of the database. All information which we pass out, derives from the RIR databases and is processed for ease of use. If you want to change or report non working abuse contacts please contact the appropriate RIR. If you have any further question, contact abusix.com directly via email (info@abusix.com). Information about the Abuse Contact Database can be found here:
39+
40+
https://abusix.com/global-reporting/abuse-contact-db
41+
42+
abusix.com is neither responsible nor liable for the content or accuracy of this message.';
43+
44+
my $config = ConfigServer::Config->loadconfig();
45+
my %config = $config->config();
46+
47+
# end main
48+
###############################################################################
49+
# start abuseip
50+
sub abuseip {
51+
my $ip = shift;
52+
my $abuse = "";
53+
my $netip;
54+
my $reversed_ip;
55+
56+
if (checkip(\$ip)) {
57+
eval {
58+
local $SIG{__DIE__} = undef;
59+
$netip = Net::IP->new($ip);
60+
$reversed_ip = $netip->reverse_ip();
61+
};
62+
63+
if ($reversed_ip =~ /^(\S+)\.in-addr\.arpa/) {$reversed_ip = $1}
64+
if ($reversed_ip =~ /^(\S+)\s+(\S+)\.in-addr\.arpa/) {$reversed_ip = $2}
65+
if ($reversed_ip =~ /^(\S+)\.ip6\.arpa/) {$reversed_ip = $1}
66+
if ($reversed_ip =~ /^(\S+)\s+(\S+)\.ip6\.arpa/) {$reversed_ip = $2}
67+
68+
if ($reversed_ip ne "") {
69+
$reversed_ip .= ".abuse-contacts.abusix.org";
70+
71+
my $cmdpid;
72+
eval {
73+
local $SIG{__DIE__} = undef;
74+
local $SIG{'ALRM'} = sub {die};
75+
alarm(10);
76+
my ($childin, $childout);
77+
$cmdpid = open3($childin, $childout, $childout, $config{HOST},"-W","5","-t","TXT",$reversed_ip);
78+
close $childin;
79+
my @results = <$childout>;
80+
waitpid ($cmdpid, 0);
81+
chomp @results;
82+
if ($results[0] =~ /^${reversed_ip}.+"(.*)"$/) {$abuse = $1}
83+
alarm(0);
84+
};
85+
alarm(0);
86+
if ($cmdpid =~ /\d+/ and $cmdpid > 1 and kill(0,$cmdpid)) {kill(9,$cmdpid)}
87+
88+
if ($abuse ne "") {
89+
my $msg = $abusemsg;
90+
$msg =~ s/\[ip\]/$ip/g;
91+
$msg =~ s/\[contact\]/$abuse/g;
92+
return $abuse, $msg;
93+
}
94+
}
95+
}
96+
}
97+
# end abuseip
98+
###############################################################################
99+
100+
1;

0 commit comments

Comments
 (0)