Skip to content

Commit 8d1add8

Browse files
authored
Merge pull request #2726 from pi-hole/development
Pi-hole FTL v6.4
2 parents a0186fd + 3a2647d commit 8d1add8

Some content is hidden

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

45 files changed

+6057
-2829
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
-
3434
name: Checkout code
35-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
35+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
3636
-
3737
name: "Calculate required variables"
3838
id: variables
@@ -100,11 +100,11 @@ jobs:
100100
steps:
101101
-
102102
name: Checkout code
103-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
103+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
104104
# QEMU should come before Buildx
105105
-
106106
name: Set up QEMU
107-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 #v3.6.0
107+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 #v3.7.0
108108
-
109109
name: Set up Docker Buildx
110110
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 #v3.11.1
@@ -265,7 +265,7 @@ jobs:
265265
-
266266
name: Attach binaries to release
267267
if: github.event_name == 'release'
268-
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 #v2.4.1
268+
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe #v2.4.2
269269
with:
270270
tag_name: ${{ github.event.release.tag_name }}
271271
files: |

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
5959
steps:
6060
- name: Checkout repository
61-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
61+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
6262

6363
- name: Install dependencies
6464
run: |
@@ -85,7 +85,7 @@ jobs:
8585
8686
# Initializes the CodeQL tools for scanning.
8787
- name: Initialize CodeQL
88-
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
88+
uses: github/codeql-action/init@e12f0178983d466f2f6028f5cc7a6d786fd97f4b #v4.31.4
8989
with:
9090
languages: ${{ matrix.language }}
9191
build-mode: ${{ matrix.build-mode }}
@@ -108,7 +108,7 @@ jobs:
108108
./build.sh
109109
110110
- name: Perform CodeQL Analysis
111-
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
111+
uses: github/codeql-action/analyze@e12f0178983d466f2f6028f5cc7a6d786fd97f4b #v4.31.4
112112
with:
113113
category: "/language:${{matrix.language}}"
114114
upload: failure-only # upload only in case of failure, otherwise upload later after filtering
@@ -134,7 +134,7 @@ jobs:
134134
output: codeql-results/cpp.sarif
135135

136136
- name: Upload SARIF
137-
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
137+
uses: github/codeql-action/upload-sarif@e12f0178983d466f2f6028f5cc7a6d786fd97f4b #v4.31.4
138138
with:
139139
sarif_file: codeql-results/cpp.sarif
140140

.github/workflows/codespell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
steps:
1414
-
1515
name: Checkout repository
16-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
16+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
1717
-
1818
name: Spell-Checking
19-
uses: codespell-project/actions-codespell@406322ec52dd7b488e48c1c4b82e2a8b3a1bf630 #v2.1
19+
uses: codespell-project/actions-codespell@8f01853be192eb0f849a5c7d721450e7a467c579 #v2.2
2020
with:
2121
ignore_words_file: .github/.codespellignore
2222
skip: ./src/database/sqlite3.c,./src/database/sqlite3.h,./src/database/shell.c,./src/lua,./src/dnsmasq,./src/tre-regex,./.git,./test/libs,./src/webserver/civetweb,./src/zip/miniz,./src/api/docs/content/external,./src/database/sqlite3_rsync.c,./package-lock.json,./src/config/tomlc17

.github/workflows/openapi-validator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- name: Clone repository
15-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
15+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
1616

1717
- name: Set up Node.js
1818
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 #v6.0.0

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ubuntu-latest
4141
steps:
4242
- name: Checkout
43-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
43+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
4444
- name: Remove 'stale' label
4545
run: gh issue edit ${{ github.event.issue.number }} --remove-label ${{ env.stale_label }}
4646
env:

.github/workflows/sync-back-to-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Syncing branches
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
14+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 #v6.0.0
1515
- name: Opening pull request
1616
run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
1717
env:

patch/sqlite3/0001-print-FTL-version-in-interactive-shell.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ index 6280ebf6..a5e82f70 100644
2020
#else
2121
int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
2222
char **argv;
23-
@@ -33467,6 +33469,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
23+
@@ -33656,6 +33658,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
24+
if( stdin_is_interactive ){
2425
char *zHome;
2526
char *zHistory;
26-
int nHistory;
2727
+ print_FTL_version();
2828
sqlite3_fprintf(stdout,
2929
"SQLite version %s %.19s\n" /*extra-version-info*/

src/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
4040
# HAVE_FDATASYNC: This option causes SQLite to try to use the fdatasync() system call to sync the database file to disk when committing a transaction. Syncing using fdatasync() is faster than syncing using fsync() as fdatasync() does not wait for the file metadata to be written to disk.
4141
# SQLITE_DEFAULT_WORKER_THREADS=0: This option sets the default number of worker threads to use when doing parallel sorting and indexing. The default is 0 which means to use a single thread. Do not increase this value as it, ironically, can cause performance degradation and definitely increases total memory usage.
4242
# SQLITE_MAX_PREPARE_RETRY=200: This option sets the maximum number of automatic re-preparation attempts that can occur after encountering a schema change. This can be caused by running ANALYZE which is done periodically by FTL.
43-
set(SQLITE_DEFINES "-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_DEFAULT_FOREIGN_KEYS=1 -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TEMP_STORE=1 -DSQLITE_DEFAULT_CACHE_SIZE=16384 -DSQLITE_DEFAULT_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DHAVE_MALLOC_H -DHAVE_MALLOC_USABLE_SIZE -DHAVE_FDATASYNC -DSQLITE_DEFAULT_WORKER_THREADS=0 -DSQLITE_MAX_PREPARE_RETRY=200")
43+
# SQLITE_ENABLE_CARRAY: Enable the carray virtual table module
44+
# SQLITE_ENABLE_PERCENTILE: Enable the percentile aggregate function
45+
set(SQLITE_DEFINES "-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_DEFAULT_FOREIGN_KEYS=1 -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TEMP_STORE=1 -DSQLITE_DEFAULT_CACHE_SIZE=16384 -DSQLITE_DEFAULT_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DHAVE_MALLOC_H -DHAVE_MALLOC_USABLE_SIZE -DHAVE_FDATASYNC -DSQLITE_DEFAULT_WORKER_THREADS=0 -DSQLITE_MAX_PREPARE_RETRY=200 -DSQLITE_ENABLE_CARRAY=1 -DSQLITE_ENABLE_PERCENTILE=1")
4446

4547
# Code hardening and debugging improvements
4648
# -fstack-protector-strong: The program will be resistant to having its stack overflowed
@@ -216,7 +218,7 @@ endif()
216218
set(CMAKE_C_FLAGS "-std=c17 -pipe ${WARN_FLAGS} -D_FILE_OFFSET_BITS=64 ${HARDENING_FLAGS} ${DEBUG_FLAGS} ${CMAKE_C_FLAGS} -DHAVE_POLL_H ${SQLITE_DEFINES}")
217219

218220
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
219-
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
221+
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -funroll-loops")
220222
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g3")
221223
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
222224

src/api/2fa.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,21 @@ static bool encode_uint8_t_array_to_base32(const uint8_t *in, const size_t in_le
195195
return true;
196196
}
197197

198+
static time_t last_attempt = 0;
198199
static uint32_t last_code = 0;
199200
enum totp_status verifyTOTP(const uint32_t incode)
200201
{
202+
// Only one attempt per second is allowed
203+
const time_t now = time(NULL);
204+
if(now == last_attempt)
205+
return TOTP_RATE_LIMIT;
206+
last_attempt = now;
207+
201208
// Decode base32 secret
202209
uint8_t decoded_secret[RFC6238_SECRET_LEN];
203210
if(!decode_base32_to_uint8_array(config.webserver.api.totp_secret.v.s, decoded_secret, sizeof(decoded_secret)))
204211
return false;
205212

206-
// Get current time
207-
const time_t now = time(NULL);
208-
209213
// Verify code for the previous, the current and the next time step
210214
for(int i = -1; i <= 1; i++)
211215
{

src/api/action.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ static int run_and_stream_command(struct ftl_conn *api, const char *path, const
121121

122122
int api_action_gravity(struct ftl_conn *api)
123123
{
124-
return run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL }, "FORCE_COLOR");
124+
// Only set FORCE_COLOR if the client explicitly requests it via "color=true" query parameter
125+
// This prevents ANSI escape codes from being included in the output for API consumers that don't need them
126+
bool color = false;
127+
const char *query = api->request != NULL ? api->request->query_string : "";
128+
if(query != NULL)
129+
get_bool_var(query, "color", &color);
130+
131+
const char *extra_env = color ? "FORCE_COLOR" : NULL;
132+
return run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL }, extra_env);
125133
}
126134

127135
int api_action_restartDNS(struct ftl_conn *api)

0 commit comments

Comments
 (0)