From 7c4e491d18f3a4999b6c1b7c852f6892756d1db8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 16:38:47 +0200 Subject: [.github/feature-branch] Fixed bad static analysis name --- .github/workflows/feature-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index 54c0c6b..86b7cfd 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -26,7 +26,7 @@ jobs: - name: Build server and browser run: make tests - Static analysis: + Static-analysis: runs-on: ubuntu-latest needs: Clone-repo steps: -- cgit v1.2.3 From d0d2937c42304b9e2805ac0ba8bd1bc2b2d7604c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:39:45 +0200 Subject: [.github/feature-branch] Reworked to properly use clone repo artifact --- .github/workflows/feature-branch.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index 86b7cfd..c7ab192 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -1,4 +1,4 @@ -name: feature-branch +name: Tests and static analysis on: push: branches-ignore: @@ -22,7 +22,10 @@ jobs: runs-on: ubuntu-latest needs: Clone-repo steps: - - uses: actions/checkout@v4 + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . - name: Build server and browser run: make tests @@ -30,7 +33,9 @@ jobs: runs-on: ubuntu-latest needs: Clone-repo steps: - - uses: actions/checkout@v4 + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . - name: Build server and browser run: make static-analysis - -- cgit v1.2.3 From 74609c69efefe6660f0befb89928787fdceaa0ae Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:40:00 +0200 Subject: [.github/dev-branch] Added initial setup --- .github/workflows/dev-branch.yml | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/dev-branch.yml diff --git a/.github/workflows/dev-branch.yml b/.github/workflows/dev-branch.yml new file mode 100644 index 0000000..ba2853d --- /dev/null +++ b/.github/workflows/dev-branch.yml @@ -0,0 +1,85 @@ +name: Tests and static analysis +on: + push: + branches: + - dev +jobs: + # This is done to prevent potential race conditions; + # multiple jobs start with the source code, but since + # they have no "needs", one could start a little bit later, + # and in meantime a commit could be pushed + Clone-repo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/upload-artifact@v3 + with: + name: source-code + path: . + + Tests: + runs-on: ubuntu-latest + needs: Clone-repo + steps: + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . + - name: Run tests + run: make tests + + Static-analysis: + runs-on: ubuntu-latest + needs: Clone-repo + steps: + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . + - name: Run satic analysis + run: make static-analysis + + Security-analysis: + runs-on: ubuntu-latest + needs: Clone-repo + steps: + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . + - name: Run security analysis + run: make security-analysis + + Build: + runs-on: ubuntu-latest + needs: [ Tests, Static-analysis, Security-analysis ] + steps: + - uses: actions/download-artifact@v3 + with: + name: source-code + path: . + - name: Build server and browser + run: make dev + - uses: actions/upload-artifact@v3 + with: + name: dev-build-files + path: ./build + + Build-docker-and-push: + name: Build the docker container image and push it to dockerhub + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: dev-build-files + path: ./build + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v5 + with: + push: true + file: Dockerfile.dev + tags: ${{ secrets.DOCKERHUB_USERNAME }}/pico-web-dev:latest -- cgit v1.2.3 From 35086fb96fc4d5bd3ef2fef566e883a9426a69a2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:40:13 +0200 Subject: [Makefile] Added security analysis --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 692aba2..73b063a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ CC_SANA ?= clang CFLAGS_SANA ?= --analyze -Xclang -analyzer-output=text +# Security analysis +CC_CANA ?= flawfinder +CFLAGS_CANA ?= --error-level=3 + .PHONY: all all: build @@ -21,6 +25,10 @@ tests: static-analysis: $(CC_SANA) $(CFLAGS_SANA) ./src/* +.PHONY: security-analysis +security-analysis: + $(CC_CANA) $(CFLAGS_CANA) ./src + .PHONY: clean clean: cd ./src/ && $(MAKE) clean -- cgit v1.2.3 From 8fe238dbfcdcd9de537c8aef360d3b6cfd2e0564 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:40:26 +0200 Subject: [Dockerfile] Added development Dockerfile --- Dockerfile.dev | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile.dev diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..328f4a6 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,10 @@ +FROM alpine:latest + +RUN apk update && apk upgrade +RUN apk add bash musl-dev gcc make gdb + +COPY ./build /usr/build + +EXPOSE 8080 +WORKDIR /usr/build +CMD /bin/bash -- cgit v1.2.3 From 772c600775ebd86a9fc8fc958b79a3e483ffc4f4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:48:04 +0200 Subject: [.github/main-branch] Added a github release step --- .github/workflows/main-branch.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main-branch.yml b/.github/workflows/main-branch.yml index d8584cb..dcd4c60 100644 --- a/.github/workflows/main-branch.yml +++ b/.github/workflows/main-branch.yml @@ -1,10 +1,10 @@ -name: Push image to dockerhub +name: Create release and push production server image to dockerhub on: push: branches: - main jobs: - build-and-push: + Build-docker-and-push: name: Build the docker container image and push it to dockerhub runs-on: ubuntu-latest steps: @@ -18,3 +18,14 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/pico-web-server:latest + Release: + name: Make github release + runs-on: ubuntu-latest + needs: Build-docker-and-push + steps: + - uses: actions/checkout@v4 + - uses: rymndhng/release-on-push-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + bump_version_scheme: minor -- cgit v1.2.3 From a71a9c37a765cde78f0085b4c21adeedb6fd819f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:48:26 +0200 Subject: [.github/dev-branch] Slight name rename --- .github/workflows/dev-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-branch.yml b/.github/workflows/dev-branch.yml index ba2853d..a7e81f6 100644 --- a/.github/workflows/dev-branch.yml +++ b/.github/workflows/dev-branch.yml @@ -1,4 +1,4 @@ -name: Tests and static analysis +name: Tests, analysis and push to dev dockerhub on: push: branches: -- cgit v1.2.3 From 24892c415af7277e79fd8d0bbfd4b886e9ac74f7 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:50:22 +0200 Subject: [tests/browser-net] Removed bad tests --- tests/browser-net.tests.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/browser-net.tests.c b/tests/browser-net.tests.c index 05a4a7c..0e0ee7b 100644 --- a/tests/browser-net.tests.c +++ b/tests/browser-net.tests.c @@ -21,23 +21,3 @@ void test_get_page_ReturnsEmptyLine_WhenURLIsBlank(void) { sdsfree(page); } - -void test_get_page_ReturnsMessage_WhenCannotConnectToServer(void) { - streq_ExpectAndReturn(URL, "blank", 0); - herrc_Expect(3, "socket"); - atop_ExpectAndReturn("0", 0); - /* aton_ExpectAndReturn("255.255.255.255", NULL, -1); */ - /* aton_IgnoreArg_output(); */ - herrc_Expect(0, "inet_aton"); - herrc_Expect(0, "connect"); - - sds page = get_page("255.255.255.255", "0", URL); - - TEST_ASSERT_EQUAL_STRING(page, "Couldn't connect to server!\n"); - - sdsfree(page); -} - -void test_get_page_ReturnsGivenPage_WhenURLIsCorrect(void) { - TEST_ASSERT_TRUE(1); -} -- cgit v1.2.3 From 1f47d1276217474d553d8b65dd64ac72f92f8a3e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:54:12 +0200 Subject: [src] Fixed angled bracket includes to quote includes where applicable --- src/browser-cli.h | 2 +- src/server-cli.c | 4 ++-- src/server-cli.h | 2 +- src/server-connection.c | 4 ++-- src/server-connection.h | 2 +- src/server.c | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/browser-cli.h b/src/browser-cli.h index a164dc9..8709231 100644 --- a/src/browser-cli.h +++ b/src/browser-cli.h @@ -1,7 +1,7 @@ #ifndef BROWSER_CLI #define BROWSER_CLI -#include +#include "sds/sds.h" void initRendering(); void freeRendering(); diff --git a/src/server-cli.c b/src/server-cli.c index 707c3ef..5e84ff6 100644 --- a/src/server-cli.c +++ b/src/server-cli.c @@ -1,5 +1,5 @@ -#include -#include +#include "util.h" +#include "server-connection.h" #include #include #include diff --git a/src/server-cli.h b/src/server-cli.h index b5b5875..8bc6ff2 100644 --- a/src/server-cli.h +++ b/src/server-cli.h @@ -1,7 +1,7 @@ #ifndef H_SERVER_CLI #define H_SERVER_CLI -#include +#include "sds/sds.h" void handleCLI(sds **vhosts, int vhostsc); diff --git a/src/server-connection.c b/src/server-connection.c index 466b259..3edd120 100644 --- a/src/server-connection.c +++ b/src/server-connection.c @@ -1,4 +1,4 @@ -#include +#include "server-connection.h" #include #include @@ -6,7 +6,7 @@ #include #include -#include +#include "util.h" sds constructFilePath(const sds root, const char* file); void sanitizeAddress(char* address); diff --git a/src/server-connection.h b/src/server-connection.h index 71447ff..689fbf4 100644 --- a/src/server-connection.h +++ b/src/server-connection.h @@ -1,7 +1,7 @@ #ifndef H_SERVER_CONNECTION #define H_SERVER_CONNECTION -#include +#include "sds/sds.h" #define vh_user 0 #define vh_path 1 diff --git a/src/server.c b/src/server.c index aeff800..1c157fe 100644 --- a/src/server.c +++ b/src/server.c @@ -14,11 +14,11 @@ #include #include -#include -#include +#include "sds/sds.h" +#include "util.h" -#include -#include +#include "server-connection.h" +#include "server-cli.h" int createCommunicationSocket(const char* ip, const char* port) { int fd_socket = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); -- cgit v1.2.3 From b32fc727fdbd67e9395cedb0a13f1a2adc03d527 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:55:36 +0200 Subject: [.github/feature-branch] Fixed names of steps --- .github/workflows/feature-branch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index c7ab192..88bee04 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -26,7 +26,7 @@ jobs: with: name: source-code path: . - - name: Build server and browser + - name: Run tests run: make tests Static-analysis: @@ -37,5 +37,5 @@ jobs: with: name: source-code path: . - - name: Build server and browser + - name: Run static analysis run: make static-analysis -- cgit v1.2.3 From fe29a3630d48d3e1d44287ea41682621d3a3dab0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 8 Jan 2024 17:59:38 +0200 Subject: [.github] Recursive submodule checkout --- .github/workflows/dev-branch.yml | 2 ++ .github/workflows/feature-branch.yml | 2 ++ .github/workflows/main-branch.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/dev-branch.yml b/.github/workflows/dev-branch.yml index a7e81f6..6d66da2 100644 --- a/.github/workflows/dev-branch.yml +++ b/.github/workflows/dev-branch.yml @@ -12,6 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: recursive - uses: actions/upload-artifact@v3 with: name: source-code diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index 88bee04..3ff1833 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: recursive - uses: actions/upload-artifact@v3 with: name: source-code diff --git a/.github/workflows/main-branch.yml b/.github/workflows/main-branch.yml index dcd4c60..8534344 100644 --- a/.github/workflows/main-branch.yml +++ b/.github/workflows/main-branch.yml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: recursive - uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} -- cgit v1.2.3