Skip to content

Commit

Permalink
Merge branch 'main' into consistent-log-tz
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam authored Jun 14, 2024
2 parents afe0cfc + 9e1e43c commit 5783984
Show file tree
Hide file tree
Showing 37 changed files with 1,432 additions and 623 deletions.
8 changes: 7 additions & 1 deletion .docker/prod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ ARG VERSION=edge
ARG GVM_LIBS_VERSION=oldstable
ARG DEBIAN_FRONTEND=noninteractive
ARG IMAGE_REGISTRY=ghcr.io
# when set it will added to the cmake command
# As an example:
# FEATURE_TOGGLES="-DOPENVASD=1"
# enables openvasd feature toggle.
ARG FEATURE_TOGGLE=""

FROM ${IMAGE_REGISTRY}/greenbone/gvmd-build:${VERSION} as builder
ARG FEATURE_TOGGLE

COPY . /source
WORKDIR /source

RUN mkdir /build && \
mkdir /install && \
cd /build && \
cmake -DCMAKE_BUILD_TYPE=Release /source && \
cmake -DCMAKE_BUILD_TYPE=Release $FEATURE_TOGGLE /source && \
make DESTDIR=/install install

FROM greenbone/gvm-libs:${GVM_LIBS_VERSION}
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
images:
name: Production Images
runs-on: ubuntu-latest
strategy:
matrix:
build:
- default
- openvasd
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -41,8 +46,9 @@ jobs:
type=ref,event=pr
# when a new git tag is created set stable and a latest tags
type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' && matrix.build == 'default'}}
type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' && matrix.build == 'default'}}
type=raw,value=edge-openvasd,enable=${{ steps.latest.outputs.is-latest-tag == 'false' && matrix.build == 'openvasd' }}
- name: Set container build options
id: container-opts
run: |
Expand All @@ -53,6 +59,11 @@ jobs:
echo "version=edge" >> $GITHUB_OUTPUT
echo "gvm-libs-version=oldstable-edge" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.build }}" = 'openvasd' ]]; then
echo 'ft=-DOPENVASD=1' >> $GITHUB_OUTPUT
else
echo 'ft=-DOPENVASD=0' >> $GITHUB_OUTPUT
fi
- name: Login to Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
Expand All @@ -71,6 +82,7 @@ jobs:
build-args: |
VERSION=${{ steps.container-opts.outputs.version }}
GVM_LIBS_VERSION=${{ steps.container-opts.outputs.gvm-libs-version }}
FEATURE_TOGGLE=${{ steps.container-opts.outputs.ft }}
IMAGE_REGISTRY=${{ vars.IMAGE_REGISTRY }}
file: .docker/prod.Dockerfile
platforms: linux/amd64,linux/arm64
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Push to Greenbone Registry

on:
push:
branches: [ main ]
tags: ["v*"]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
building:
runs-on: self-hosted-generic
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: greenbone/actions/is-latest-tag@v3
id: latest

- name: Set container build options
id: container-opts
run: |
if [[ "${{ github.ref_type }}" = 'tag' ]]; then
echo "version=stable" >> $GITHUB_OUTPUT
echo "gvm-libs-version=oldstable" >> $GITHUB_OUTPUT
else
echo "version=edge" >> $GITHUB_OUTPUT
echo "gvm-libs-version=oldstable-edge" >> $GITHUB_OUTPUT
fi
- name: Build and Push Container
id: build-and-push
uses: greenbone/actions/container-build-push-generic@v3
with:
build-docker-file: .docker/prod.Dockerfile
build-args: |
VERSION=${{ steps.container-opts.outputs.version }}
GVM_LIBS_VERSION=${{ steps.container-opts.outputs.gvm-libs-version }}
IMAGE_REGISTRY=${{ vars.IMAGE_REGISTRY }}
cosign-key: ${{ secrets.COSIGN_KEY_OPENSIGHT }}
cosign-key-password: ${{ secrets.COSIGN_KEY_PASSWORD_OPENSIGHT }}
cosign-tlog-upload: "false"
image-url: community/gvmd
image-labels: |
org.opencontainers.image.vendor=Greenbone
org.opencontainers.image.base.name=greenbone/gvm-libs
image-tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge
type=ref,event=pr
type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
registry: ${{ secrets.GREENBONE_REGISTRY }}
registry-username: ${{ secrets.GREENBONE_REGISTRY_USER }}
registry-password: ${{ secrets.GREENBONE_REGISTRY_TOKEN }}
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 255)
set (GVMD_DATABASE_VERSION 256)

set (GVMD_SCAP_DATABASE_VERSION 21)

Expand Down Expand Up @@ -235,6 +235,11 @@ if (NOT GVM_DEFAULT_DROP_USER)
set (GVM_DEFAULT_DROP_USER "")
endif (NOT GVM_DEFAULT_DROP_USER)


if (NOT OPENVASD)
set (OPENVASD 0)
endif (NOT OPENVASD)

message ("-- Install prefix: ${CMAKE_INSTALL_PREFIX}")

## Version
Expand Down Expand Up @@ -275,7 +280,7 @@ set (HARDENING_FLAGS "-Wformat -Wformat-security -D_FORTIFY_SOURCE=2
set (LINKER_HARDENING_FLAGS "-Wl,-z,relro -Wl,-z,now")

# To find unused functions, add: -flto -fwhole-program -ffunction-sections -Wl,--gc-sections -Wl,--print-gc-sections
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -D_BSD_SOURCE -D_ISOC99_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE -D_FILE_OFFSET_BITS=64")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -D_BSD_SOURCE -D_ISOC99_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE -D_FILE_OFFSET_BITS=64 -DOPENVASD=${OPENVASD}")

set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wshadow ${COVERAGE_FLAGS} ${DEBUG_FUNCTION_NAMES_FLAGS}")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${HARDENING_FLAGS} ${COVERAGE_FLAGS}")
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ find_package (Threads)
## might occur.

pkg_check_modules (CJSON REQUIRED libcjson>=1.7.14)
pkg_check_modules (LIBGVM_BASE REQUIRED libgvm_base>=22.9)
pkg_check_modules (LIBGVM_UTIL REQUIRED libgvm_util>=22.9)
pkg_check_modules (LIBGVM_OSP REQUIRED libgvm_osp>=22.9)
pkg_check_modules (LIBGVM_GMP REQUIRED libgvm_gmp>=22.9)
pkg_check_modules (LIBGVM_BASE REQUIRED libgvm_base>=22.10)
pkg_check_modules (LIBGVM_UTIL REQUIRED libgvm_util>=22.10)
pkg_check_modules (LIBGVM_OSP REQUIRED libgvm_osp>=22.10)
pkg_check_modules (LIBGVM_GMP REQUIRED libgvm_gmp>=22.10)
pkg_check_modules (GNUTLS REQUIRED gnutls>=3.2.15)
pkg_check_modules (GLIB REQUIRED glib-2.0>=2.42)
pkg_check_modules (LIBBSD REQUIRED libbsd)
Expand Down
Loading

0 comments on commit 5783984

Please sign in to comment.