Skip to content

Commit

Permalink
feat(fips): add fips compliant packages (#175)
Browse files Browse the repository at this point in the history
* feat(fips): add fips compliant packages

* update dependence on fips agent
  • Loading branch information
rajrohanyadav authored Feb 3, 2025
1 parent dc8463e commit 3caa607
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 80 deletions.
1 change: 1 addition & 0 deletions .github/workflows/on_prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jobs:
with:
tag: ${{ github.event.release.tag_name }}
integration: mysql
upload_fips_packages: true
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/on_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ jobs:
with:
integration: mysql
tag: ${{ github.event.release.tag_name }}
upload_fips_packages: true
secrets: inherit
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Unreleased section should follow [Release Toolkit](https://github.com/newrelic/r

## Unreleased

### enhancements
- Add FIPS compliant packages

## v1.12.0 - 2025-01-20

### 🚀 Enhancements
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CONFIG_DIR = /etc/newrelic-infra/integrations.d
GO_FILES := ./src/
GOFLAGS = -mod=readonly
GOLANGCI_LINT = github.com/golangci/golangci-lint/cmd/golangci-lint
GO_VERSION ?= $(shell grep '^go ' go.mod | awk '{print $$2}')
BUILDER_IMAGE ?= "ghcr.io/newrelic/coreint-automation:latest-go$(GO_VERSION)-ubuntu16.04"

all: build

Expand Down
93 changes: 89 additions & 4 deletions build/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
version: 2
project_name: nri-mysql
builds:
- id: nri-mysql-nix
main: ./src
Expand All @@ -17,6 +20,26 @@ builds:
ignore:
- goos: darwin
goarch: 386

- id: nri-mysql-nix-fips
main: ./src
binary: nri-mysql
ldflags:
- -s -w -X main.integrationVersion={{.Version}} -X main.gitCommit={{.Commit}} -X main.buildDate={{.Date}}
env:
- CGO_ENABLED=1
- GOEXPERIMENT=boringcrypto
- >-
{{- if eq .Arch "arm64" -}}
CC=aarch64-linux-gnu-gcc
{{- end }}
goos:
- linux
goarch:
- amd64
- arm64
tags:
- fips

- id: nri-mysql-win
main: ./src
Expand All @@ -35,7 +58,8 @@ builds:

nfpms:
- id: linux
file_name_template: "{{ .ProjectName }}_{{ .Version }}-1_{{ .Arch }}"
package_name: nri-mysql
file_name_template: "{{ .PackageName }}_{{ .Version }}-1_{{ .Arch }}"
vendor: "New Relic, Inc."
homepage: "https://www.newrelic.com/infrastructure"
maintainer: "New Relic Infrastructure Team <[email protected]>"
Expand Down Expand Up @@ -67,9 +91,59 @@ nfpms:

overrides:
rpm:
file_name_template: "{{ .ProjectName }}-{{ .Version }}-1.{{ .Arch }}"
replacements:
amd64: x86_64
file_name_template: >-
{{- .ProjectName }}-
{{- .Version }}-1.
{{- if eq .Arch "amd64" -}}x86_64
{{- else -}}
{{ .Arch }}
{{- end }}
formats:
- deb
- rpm

- id: linux-fips
package_name: nri-mysql-fips
file_name_template: "{{ .PackageName }}_{{ .Version }}-1_{{ .Arch }}"
vendor: "New Relic, Inc."
homepage: "https://www.newrelic.com/infrastructure"
maintainer: "New Relic Infrastructure Team <[email protected]>"
description: "New Relic Infrastructure mysql Integration extend the core New Relic\nInfrastructure agent's capabilities to allow you to collect metric and\nlive state data from mysql components."
license: "https://newrelic.com/terms (also see LICENSE installed with this package)"

builds:
- nri-mysql-nix-fips

dependencies:
- newrelic-infra-fips (>= 1.60.0)

bindir: "/var/db/newrelic-infra/newrelic-integrations/bin"

contents:
- src: "mysql-config.yml.sample"
dst: "/etc/newrelic-infra/integrations.d/mysql-config.yml.sample"
- src: "mysql-log.yml.example"
dst: "/etc/newrelic-infra/logging.d/mysql-log.yml.example"
- src: "CHANGELOG.md"
dst: "/usr/share/doc/nri-mysql/CHANGELOG.md"
- src: "README.md"
dst: "/usr/share/doc/nri-mysql/README.md"
- src: "LICENSE"
dst: "/usr/share/doc/nri-mysql/LICENSE"
- src: "legacy/mysql-definition.yml"
dst: "/var/db/newrelic-infra/newrelic-integrations/mysql-definition.yml"
type: config

overrides:
rpm:
file_name_template: >-
{{- .ProjectName }}-fips-
{{- .Version }}-1.
{{- if eq .Arch "amd64" -}}x86_64
{{- else -}}
{{ .Arch }}
{{- end }}
formats:
- deb
Expand All @@ -87,6 +161,17 @@ archives:
strip_parent: true
format: tar.gz

- id: nri-mysql-nix-fips
builds:
- nri-mysql-nix-fips
name_template: "{{ .ProjectName }}-fips_{{ .Os }}_{{ .Version }}_{{ .Arch }}_dirty"
files:
- mysql-config.yml.sample
- src: 'legacy/mysql-definition.yml'
dst: .
strip_parent: true
format: tar.gz

- id: nri-mysql-win
builds:
- nri-mysql-win
Expand Down
18 changes: 0 additions & 18 deletions build/Dockerfile

This file was deleted.

15 changes: 8 additions & 7 deletions build/ci.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
BUILDER_TAG ?= nri-$(INTEGRATION)-builder
.PHONY : ci/pull-builder-image
ci/pull-builder-image:
@docker pull $(BUILDER_IMAGE)

.PHONY : ci/deps
ci/deps:
@docker build -t $(BUILDER_TAG) -f $(CURDIR)/build/Dockerfile $(CURDIR)
ci/deps: ci/pull-builder-image

.PHONY : ci/debug-container
ci/debug-container: ci/deps
Expand All @@ -17,15 +18,15 @@ ci/debug-container: ci/deps
-e GPG_MAIL \
-e GPG_PASSPHRASE \
-e GPG_PRIVATE_KEY_BASE64 \
$(BUILDER_TAG) bash
$(BUILDER_IMAGE) bash

.PHONY : ci/test
ci/test: ci/deps
@docker run --rm -t \
--name "nri-$(INTEGRATION)-test" \
-v $(CURDIR):/go/src/github.com/newrelic/nri-$(INTEGRATION) \
-w /go/src/github.com/newrelic/nri-$(INTEGRATION) \
$(BUILDER_TAG) make test
$(BUILDER_IMAGE) make test

.PHONY : ci/snyk-test
ci/snyk-test:
Expand All @@ -46,7 +47,7 @@ ifdef TAG
-w /go/src/github.com/newrelic/nri-$(INTEGRATION) \
-e INTEGRATION \
-e TAG \
$(BUILDER_TAG) make release/build
$(BUILDER_IMAGE) make release/build
else
@echo "===> $(INTEGRATION) === [ci/build] TAG env variable expected to be set"
exit 1
Expand All @@ -67,7 +68,7 @@ ifdef TAG
-e GPG_MAIL \
-e GPG_PASSPHRASE \
-e GPG_PRIVATE_KEY_BASE64 \
$(BUILDER_TAG) make release
$(BUILDER_IMAGE) make release
else
@echo "===> $(INTEGRATION) === [ci/prerelease] TAG env variable expected to be set"
exit 1
Expand Down
47 changes: 0 additions & 47 deletions build/nix/sign.sh

This file was deleted.

8 changes: 4 additions & 4 deletions build/release.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BUILD_DIR := ./bin/
GORELEASER_VERSION := v0.174.1
GORELEASER_VERSION := v2.4.4
GORELEASER_BIN ?= bin/goreleaser

bin:
Expand Down Expand Up @@ -27,10 +27,10 @@ release/deps: $(GORELEASER_BIN)
release/build: release/deps release/clean
ifeq ($(PRERELEASE), true)
@echo "===> $(INTEGRATION) === [release/build] PRE-RELEASE compiling all binaries, creating packages, archives"
@$(GORELEASER_BIN) release --config $(CURDIR)/build/.goreleaser.yml --rm-dist
@$(GORELEASER_BIN) release --config $(CURDIR)/build/.goreleaser.yml --clean
else
@echo "===> $(INTEGRATION) === [release/build] build compiling all binaries"
@$(GORELEASER_BIN) build --config $(CURDIR)/build/.goreleaser.yml --snapshot --rm-dist
@$(GORELEASER_BIN) build --config $(CURDIR)/build/.goreleaser.yml --snapshot --clean
endif

.PHONY : release/fix-archive
Expand All @@ -43,7 +43,7 @@ release/fix-archive:
.PHONY : release/sign/nix
release/sign/nix:
@echo "===> $(INTEGRATION) === [release/sign] signing packages"
@bash $(CURDIR)/build/nix/sign.sh
@bash sign.sh


.PHONY : release/publish
Expand Down
11 changes: 11 additions & 0 deletions src/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2025 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//go:build fips
// +build fips

package main

import (
_ "crypto/tls/fipsonly"
)

0 comments on commit 3caa607

Please sign in to comment.