Skip to content

Commit d08b4de

Browse files
authored
Merge pull request #6832 from acmesh-official/dev
sync
2 parents f39d066 + cc677ba commit d08b4de

33 files changed

Lines changed: 653 additions & 185 deletions

.github/copilot-instructions.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# GitHub Copilot Shell Scripting (sh) Review Instructions
2+
3+
## 🎯 Overall Goal
4+
5+
Your role is to act as a rigorous yet helpful senior engineer, reviewing Shell script code (`.sh` files). Ensure the code exhibits the highest levels of robustness, security, and portability.
6+
The review must focus on risks unique to Shell scripting, such as proper quoting, robust error handling, and the secure execution of external commands.
7+
8+
## 📝 Required Output Format
9+
10+
Please adhere to the previous format: organize the feedback into a single, structured report, using the three-level marking system:
11+
12+
1. **🔴 Critical Issues (Must Fix Before Merge)**
13+
2. **🟡 Suggestions (Improvements to Consider)**
14+
3. **✅ Good Practices (Points to Commend)**
15+
16+
---
17+
18+
## 🔍 Focus Areas and Rules for Shell
19+
20+
### 1. Robustness and Error Handling
21+
22+
* **Shebang:** Check that the script starts with the correct Shebang, must be "#!/usr/bin/env sh".
23+
* **Startup Options:** **(🔴 Critical)** Enforce the use of the following combination at the start of the script for safety and robustness:
24+
* `set -e`: Exit immediately if a command exits with a non-zero status.
25+
* `set -u`: Treat unset variables as an error and exit.
26+
* `set -o pipefail`: Ensure the whole pipeline fails if any command in the pipe fails.
27+
* **Exit Codes:** Ensure functions and the main script use `exit 0` for success and a non-zero exit code upon failure.
28+
* **Temporary Files:** Check for the use of `mktemp` when creating temporary files to prevent race conditions and security risks.
29+
30+
### 2. Security and Quoting
31+
32+
* **Variable Quoting:** **(🔴 Critical)** Check that all variable expansions (like `$VAR` and `$(COMMAND)`) are properly enclosed in **double quotes** (i.e., `"$VAR"` and `"$(COMMAND)"`) to prevent **Word Splitting** and **Globbing**.
33+
* **Hardcoded Secrets:** **(🔴 Critical)** Find and flag any hardcoded passwords, keys, tokens, or authentication details.
34+
* **Untrusted Input:** Verify that all user input, command-line arguments (`$1`, `$2`, etc.), or environment variables are rigorously validated and sanitized before use.
35+
* **Avoid `eval`:** Warn against and suggest alternatives to using `eval`, as it can lead to arbitrary code execution.
36+
37+
### 3. Readability and Maintainability
38+
39+
* **Function Usage:** Recommend wrapping complex or reusable logic within clearly named functions.
40+
* **Local Variables:** Check that variables inside functions are declared using the `local` keyword to avoid unintentionally modifying global state.
41+
* **Naming Convention:** Variable names should use uppercase letters and underscores (e.g., `MY_VARIABLE`), or follow established project conventions.
42+
* **Test Conditions:** Encourage the use of Bash's **double brackets `[[ ... ]]`** for conditional tests, as it is generally safer and more powerful (e.g., supports pattern matching and avoids Word Splitting) than single brackets `[ ... ]`.
43+
* **Command Substitution:** Encourage using `$(command)` over backticks `` `command` `` for command substitution, as it is easier to nest and improves readability.
44+
45+
### 4. External Commands and Environment
46+
47+
* **`for` Loops:** Warn against patterns like `for i in $(cat file)` or `for i in $(ls)` and recommend the more robust `while IFS= read -r line` pattern for safely processing file contents or filenames that might contain spaces.
48+
* **Use existing acme.sh functions whenever possible.** For example: do not use `tr '[:upper:]' '[:lower:]'`, use `_lower_case` instead.
49+
* **Do not use `head -n`.** Use the `_head_n()` function instead.
50+
* **Do not use `curl` or `wget`.** Use the `_post()` and `_get()` functions instead.
51+
52+
---
53+
54+
### 5. Review Rules for Files Under `dnsapi/`:
55+
56+
* **Each file must contain a `{filename}_add` function** for adding DNS TXT records. It should use `_readaccountconf_mutable` to read the API key and `_saveaccountconf_mutable` to save it. Do not use `_saveaccountconf` or `_readaccountconf`.
57+
58+
59+
## ❌ Things to Avoid
60+
61+
* Do not comment on purely stylistic issues like spacing or indentation, which should be handled by tools like ShellCheck or Prettier.
62+
* Do not be overly verbose unless a significant issue is found. Keep feedback concise and actionable.
63+
64+
65+
66+
67+

.github/workflows/DNS.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
TokenName4: ${{ secrets.TokenName4}}
6767
TokenName5: ${{ secrets.TokenName5}}
6868
steps:
69-
- uses: actions/checkout@v4
69+
- uses: actions/checkout@v6
7070
- name: Clone acmetest
7171
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
7272
- name: Set env file
@@ -114,7 +114,7 @@ jobs:
114114
TokenName4: ${{ secrets.TokenName4}}
115115
TokenName5: ${{ secrets.TokenName5}}
116116
steps:
117-
- uses: actions/checkout@v4
117+
- uses: actions/checkout@v6
118118
- name: Install tools
119119
run: brew install socat
120120
- name: Clone acmetest
@@ -165,7 +165,7 @@ jobs:
165165
- name: Set git to use LF
166166
run: |
167167
git config --global core.autocrlf false
168-
- uses: actions/checkout@v4
168+
- uses: actions/checkout@v6
169169
- name: Install cygwin base packages with chocolatey
170170
run: |
171171
choco config get cacheLocation
@@ -224,7 +224,7 @@ jobs:
224224
TokenName4: ${{ secrets.TokenName4}}
225225
TokenName5: ${{ secrets.TokenName5}}
226226
steps:
227-
- uses: actions/checkout@v4
227+
- uses: actions/checkout@v6
228228
- name: Clone acmetest
229229
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
230230
- uses: vmactions/freebsd-vm@v1
@@ -251,7 +251,7 @@ jobs:
251251
fi
252252
cd ../acmetest
253253
./letest.sh
254-
- name: onError
254+
- name: DebugOnError
255255
if: ${{ failure() }}
256256
run: |
257257
echo "See how to debug in VM:"
@@ -279,7 +279,7 @@ jobs:
279279
TokenName4: ${{ secrets.TokenName4}}
280280
TokenName5: ${{ secrets.TokenName5}}
281281
steps:
282-
- uses: actions/checkout@v4
282+
- uses: actions/checkout@v6
283283
- name: Clone acmetest
284284
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
285285
- uses: vmactions/openbsd-vm@v1
@@ -306,7 +306,7 @@ jobs:
306306
fi
307307
cd ../acmetest
308308
./letest.sh
309-
- name: onError
309+
- name: DebugOnError
310310
if: ${{ failure() }}
311311
run: |
312312
echo "See how to debug in VM:"
@@ -334,7 +334,7 @@ jobs:
334334
TokenName4: ${{ secrets.TokenName4}}
335335
TokenName5: ${{ secrets.TokenName5}}
336336
steps:
337-
- uses: actions/checkout@v4
337+
- uses: actions/checkout@v6
338338
- name: Clone acmetest
339339
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
340340
- uses: vmactions/netbsd-vm@v1
@@ -362,7 +362,7 @@ jobs:
362362
fi
363363
cd ../acmetest
364364
./letest.sh
365-
- name: onError
365+
- name: DebugOnError
366366
if: ${{ failure() }}
367367
run: |
368368
echo "See how to debug in VM:"
@@ -390,7 +390,7 @@ jobs:
390390
TokenName4: ${{ secrets.TokenName4}}
391391
TokenName5: ${{ secrets.TokenName5}}
392392
steps:
393-
- uses: actions/checkout@v4
393+
- uses: actions/checkout@v6
394394
- name: Clone acmetest
395395
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
396396
- uses: vmactions/dragonflybsd-vm@v1
@@ -418,7 +418,7 @@ jobs:
418418
fi
419419
cd ../acmetest
420420
./letest.sh
421-
- name: onError
421+
- name: DebugOnError
422422
if: ${{ failure() }}
423423
run: |
424424
echo "See how to debug in VM:"
@@ -450,7 +450,7 @@ jobs:
450450
TokenName4: ${{ secrets.TokenName4}}
451451
TokenName5: ${{ secrets.TokenName5}}
452452
steps:
453-
- uses: actions/checkout@v4
453+
- uses: actions/checkout@v6
454454
- name: Clone acmetest
455455
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
456456
- uses: vmactions/solaris-vm@v1
@@ -480,7 +480,7 @@ jobs:
480480
fi
481481
cd ../acmetest
482482
./letest.sh
483-
- name: onError
483+
- name: DebugOnError
484484
if: ${{ failure() }}
485485
run: |
486486
echo "See how to debug in VM:"
@@ -508,7 +508,7 @@ jobs:
508508
TokenName4: ${{ secrets.TokenName4}}
509509
TokenName5: ${{ secrets.TokenName5}}
510510
steps:
511-
- uses: actions/checkout@v4
511+
- uses: actions/checkout@v6
512512
- name: Clone acmetest
513513
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
514514
- uses: vmactions/omnios-vm@v1
@@ -534,7 +534,7 @@ jobs:
534534
fi
535535
cd ../acmetest
536536
./letest.sh
537-
- name: onError
537+
- name: DebugOnError
538538
if: ${{ failure() }}
539539
run: |
540540
echo "See how to debug in VM:"
@@ -563,7 +563,7 @@ jobs:
563563
TokenName4: ${{ secrets.TokenName4}}
564564
TokenName5: ${{ secrets.TokenName5}}
565565
steps:
566-
- uses: actions/checkout@v4
566+
- uses: actions/checkout@v6
567567
- name: Clone acmetest
568568
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
569569
- uses: vmactions/openindiana-vm@v1
@@ -589,7 +589,7 @@ jobs:
589589
fi
590590
cd ../acmetest
591591
./letest.sh
592-
- name: onError
592+
- name: DebugOnError
593593
if: ${{ failure() }}
594594
run: |
595595
echo "See how to debug in VM:"
@@ -618,7 +618,7 @@ jobs:
618618
TokenName4: ${{ secrets.TokenName4}}
619619
TokenName5: ${{ secrets.TokenName5}}
620620
steps:
621-
- uses: actions/checkout@v4
621+
- uses: actions/checkout@v6
622622
- name: Clone acmetest
623623
run: cd .. && git clone --depth=1 https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
624624
- uses: vmactions/haiku-vm@v1
@@ -648,7 +648,7 @@ jobs:
648648
fi
649649
cd ../acmetest
650650
./letest.sh
651-
- name: onError
651+
- name: DebugOnError
652652
if: ${{ failure() }}
653653
run: |
654654
echo "See how to debug in VM:"

.github/workflows/DragonFlyBSD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
4646
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
4747
steps:
48-
- uses: actions/checkout@v4
49-
- uses: vmactions/cf-tunnel@v0
48+
- uses: actions/checkout@v6
49+
- uses: anyvm-org/cf-tunnel@v0
5050
id: tunnel
5151
with:
5252
protocol: http
@@ -67,7 +67,7 @@ jobs:
6767
run: |
6868
cd ../acmetest \
6969
&& ./letest.sh
70-
- name: onError
70+
- name: DebugOnError
7171
if: ${{ failure() }}
7272
run: |
7373
echo "See how to debug in VM:"

.github/workflows/FreeBSD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
5252
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
5353
steps:
54-
- uses: actions/checkout@v4
55-
- uses: vmactions/cf-tunnel@v0
54+
- uses: actions/checkout@v6
55+
- uses: anyvm-org/cf-tunnel@v0
5656
id: tunnel
5757
with:
5858
protocol: http
@@ -72,7 +72,7 @@ jobs:
7272
run: |
7373
cd ../acmetest \
7474
&& ./letest.sh
75-
- name: onError
75+
- name: DebugOnError
7676
if: ${{ failure() }}
7777
run: |
7878
echo "See how to debug in VM:"

.github/workflows/Haiku.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
5353
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
5454
steps:
55-
- uses: actions/checkout@v4
56-
- uses: vmactions/cf-tunnel@v0
55+
- uses: actions/checkout@v6
56+
- uses: anyvm-org/cf-tunnel@v0
5757
id: tunnel
5858
with:
5959
protocol: http
@@ -75,7 +75,7 @@ jobs:
7575
run: |
7676
cd ../acmetest \
7777
&& ./letest.sh
78-
- name: onError
78+
- name: DebugOnError
7979
if: ${{ failure() }}
8080
run: |
8181
echo "See how to debug in VM:"

.github/workflows/Linux.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ jobs:
3333
TEST_PREFERRED_CHAIN: (STAGING)
3434
TEST_ACME_Server: "LetsEncrypt.org_test"
3535
steps:
36-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v6
37+
- uses: anyvm-org/cf-tunnel@v0
38+
id: tunnel
39+
with:
40+
protocol: http
41+
port: 80
42+
- name: Set envs
43+
run: echo "TestingDomain=${{steps.tunnel.outputs.server}}" >> $GITHUB_ENV
3744
- name: Clone acmetest
3845
run: |
3946
cd .. \

.github/workflows/MacOS.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ jobs:
4444
CA_EMAIL: ${{ matrix.CA_EMAIL }}
4545
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
4646
steps:
47-
- uses: actions/checkout@v4
47+
- uses: actions/checkout@v6
4848
- name: Install tools
4949
run: brew install socat
50+
- uses: anyvm-org/cf-tunnel@v0
51+
id: tunnel
52+
with:
53+
protocol: http
54+
port: 80
55+
- name: Set envs
56+
run: echo "TestingDomain=${{steps.tunnel.outputs.server}}" >> $GITHUB_ENV
5057
- name: Clone acmetest
5158
run: |
5259
cd .. \

.github/workflows/NetBSD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
4646
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
4747
steps:
48-
- uses: actions/checkout@v4
49-
- uses: vmactions/cf-tunnel@v0
48+
- uses: actions/checkout@v6
49+
- uses: anyvm-org/cf-tunnel@v0
5050
id: tunnel
5151
with:
5252
protocol: http
@@ -67,7 +67,7 @@ jobs:
6767
run: |
6868
cd ../acmetest \
6969
&& ./letest.sh
70-
- name: onError
70+
- name: DebugOnError
7171
if: ${{ failure() }}
7272
run: |
7373
echo "See how to debug in VM:"

.github/workflows/Omnios.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
5252
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
5353
steps:
54-
- uses: actions/checkout@v4
55-
- uses: vmactions/cf-tunnel@v0
54+
- uses: actions/checkout@v6
55+
- uses: anyvm-org/cf-tunnel@v0
5656
id: tunnel
5757
with:
5858
protocol: http
@@ -71,7 +71,7 @@ jobs:
7171
run: |
7272
cd ../acmetest \
7373
&& ./letest.sh
74-
- name: onError
74+
- name: DebugOnError
7575
if: ${{ failure() }}
7676
run: |
7777
echo "See how to debug in VM:"

.github/workflows/OpenBSD.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
TEST_PREFERRED_CHAIN: ${{ matrix.TEST_PREFERRED_CHAIN }}
5252
ACME_USE_WGET: ${{ matrix.ACME_USE_WGET }}
5353
steps:
54-
- uses: actions/checkout@v4
55-
- uses: vmactions/cf-tunnel@v0
54+
- uses: actions/checkout@v6
55+
- uses: anyvm-org/cf-tunnel@v0
5656
id: tunnel
5757
with:
5858
protocol: http
@@ -72,7 +72,7 @@ jobs:
7272
run: |
7373
cd ../acmetest \
7474
&& ./letest.sh
75-
- name: onError
75+
- name: DebugOnError
7676
if: ${{ failure() }}
7777
run: |
7878
echo "See how to debug in VM:"

0 commit comments

Comments
 (0)