Skip to content

Commit 9852c06

Browse files
committed
feat: Initial release
0 parents  commit 9852c06

File tree

8 files changed

+456
-0
lines changed

8 files changed

+456
-0
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: github-actions
5+
directory: /
6+
schedule:
7+
interval: monthly

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
name: Release
3+
'on':
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
schedule:
9+
- cron: "0 7 * * 0"
10+
11+
env:
12+
IMAGE_NAME: fixbuf
13+
14+
jobs:
15+
16+
# Test the image builds and works correctly.
17+
test:
18+
name: Test
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Check out the codebase.
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python 3.
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.x'
29+
30+
- name: Install test dependencies.
31+
run: pip3 install pytest-testinfra
32+
33+
- name: Build image.
34+
run: docker build -t cmusei/${{ env.IMAGE_NAME }} .
35+
36+
- name: Run the built image.
37+
run: docker run --name=${{ env.IMAGE_NAME }} -td cmusei/${{ env.IMAGE_NAME }}
38+
39+
- name: Test the built image.
40+
run: py.test --hosts='docker://${{ env.IMAGE_NAME }}'
41+
42+
# If on main branch, build and release image.
43+
release2:
44+
name: Release2
45+
runs-on: ubuntu-latest
46+
needs: test
47+
if: github.ref == 'refs/heads/main'
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
- uses: docker/setup-qemu-action@v3
52+
- uses: docker/setup-buildx-action@v3
53+
54+
- name: Login to DockerHub
55+
uses: docker/login-action@v3
56+
with:
57+
username: ${{ secrets.DOCKER_USERNAME }}
58+
password: ${{ secrets.DOCKER_PASSWORD }}
59+
60+
- name: Log in to the Container registry
61+
uses: docker/login-action@v3
62+
with:
63+
registry: ghcr.io
64+
username: ${{ github.actor }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Build and push image.
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: ./
71+
file: Dockerfile
72+
platforms: linux/amd64,linux/arm64
73+
push: true
74+
tags: |
75+
cmusei/${{ env.IMAGE_NAME }}:latest
76+
cmusei/${{ env.IMAGE_NAME }}:2
77+
cmusei/${{ env.IMAGE_NAME }}:2.5.0
78+
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:latest
79+
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:2
80+
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:2.5.0
81+
release3:
82+
name: Release3
83+
runs-on: ubuntu-latest
84+
needs: test
85+
if: github.ref == 'refs/heads/main'
86+
87+
steps:
88+
- uses: actions/checkout@v4
89+
- uses: docker/setup-qemu-action@v3
90+
- uses: docker/setup-buildx-action@v3
91+
92+
- name: Login to DockerHub
93+
uses: docker/login-action@v3
94+
with:
95+
username: ${{ secrets.DOCKER_USERNAME }}
96+
password: ${{ secrets.DOCKER_PASSWORD }}
97+
98+
- name: Log in to the Container registry
99+
uses: docker/login-action@v3
100+
with:
101+
registry: ghcr.io
102+
username: ${{ github.actor }}
103+
password: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Build and push image.
106+
uses: docker/build-push-action@v6
107+
with:
108+
context: ./
109+
file: Dockerfile
110+
platforms: linux/amd64,linux/arm64
111+
push: true
112+
build-args: |
113+
FIXBUF_VERSION=3.0.0.alpha2
114+
tags: |
115+
cmusei/${{ env.IMAGE_NAME }}:3
116+
ghcr.io/cmu-sei/${{ env.IMAGE_NAME }}:3

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__/
2+
inventory
3+
pytest_junit.xml

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM debian:11 AS build
2+
3+
# Specify software versions to download
4+
ARG FIXBUF_VERSION=2.5.0
5+
6+
# Pre-reqs:
7+
# curl for downloading
8+
# build-essentials for build tools
9+
# ca-certs to download https
10+
# glib2.0 for fixbuf
11+
RUN apt-get update && apt-get install -y --no-install-recommends \
12+
curl \
13+
build-essential \
14+
ca-certificates \
15+
libssl-dev \
16+
libglib2.0-dev \
17+
&& apt-get clean && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
RUN mkdir /netsa
21+
WORKDIR /netsa
22+
23+
# Download & Install fixbuf
24+
RUN curl https://tools.netsa.cert.org/releases/libfixbuf-$FIXBUF_VERSION.tar.gz | \
25+
tar -xz && cd libfixbuf-* && \
26+
./configure --prefix=/netsa \
27+
--with-openssl && \
28+
make && \
29+
make install && \
30+
cd ../ && rm -rf libfixbuf-$FIXBUF_VERSION
31+
32+
FROM debian:11-slim
33+
LABEL maintainer="[email protected]"
34+
35+
RUN mkdir /netsa
36+
37+
RUN apt-get update && apt-get install -y --no-install-recommends \
38+
libssl1.1 \
39+
pkg-config \
40+
libglib2.0-0 \
41+
&& apt-get clean && \
42+
rm -rf /var/lib/apt/lists/*
43+
44+
ENV PATH=$PATH:/netsa/bin
45+
46+
COPY --from=build /netsa/ /netsa/

LICENSE

Lines changed: 133 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# source: https://jmkhael.io/makefiles-for-your-dockerfiles/
2+
# Run in parallel via make -j2 see: https://stackoverflow.com/a/9220818
3+
4+
NS = cmusei
5+
export SOFTWARE_NAME = fixbuf
6+
7+
export IMAGE_NAME += $(NS)/$(SOFTWARE_NAME)
8+
9+
export WORK_DIR = .
10+
11+
.PHONY: build build2 build3 test
12+
13+
build: build2
14+
15+
build2:
16+
docker build --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy -t $(IMAGE_NAME):latest -f Dockerfile .
17+
docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):2
18+
19+
build3:
20+
docker build --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy --build-arg FIXBUF_VERSION=3.0.0.alpha2 -t $(IMAGE_NAME):3 -f Dockerfile .
21+
22+
test:
23+
docker rm -f $(SOFTWARE_NAME)
24+
docker run --name=$(SOFTWARE_NAME) -td $(IMAGE_NAME)
25+
py.test --hosts='docker://$(SOFTWARE_NAME)'
26+
docker rm -f $(SOFTWARE_NAME)
27+
28+
default: build

README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[![Software Engineering Institute](https://avatars.githubusercontent.com/u/12465755?s=200&v=4)](https://www.sei.cmu.edu/)
2+
3+
[![Blog](https://img.shields.io/static/v1.svg?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=SEI&message=Blog)](https://insights.sei.cmu.edu/blog/ "blog posts from our experts in Software Engineering.")
4+
[![Youtube](https://img.shields.io/static/v1.svg?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=SEI&message=Youtube&logo=youtube)](https://www.youtube.com/@TheSEICMU/ "vidoes from our experts in Software Engineering.")
5+
[![Podcasts](https://img.shields.io/static/v1.svg?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=SEI&message=Podcasts&logo=applepodcasts)](https://insights.sei.cmu.edu/podcasts/ "podcasts from our experts in Software Engineering.")
6+
[![GitHub](https://img.shields.io/static/v1.svg?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=SEI&message=GitHub&logo=github)](https://github.com/cmu-sei "view the source for all of our repositories.")
7+
[![Flow Tools](https://img.shields.io/static/v1.svg?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=SEI&message=Flow%20Tools)](https://tools.netsa.cert.org/ "documentation and source for all our flow collection and analysis tools.")
8+
9+
10+
At the [SEI](https://www.sei.cmu.edu/), we research software engineering, cybersecurity, and AI engineering problems; create innovative technologies; and put solutions into practice.
11+
12+
Find us at:
13+
14+
* [Blog](https://insights.sei.cmu.edu/blog/) - blog posts from our experts in Software Engineering.
15+
* [Youtube](https://www.youtube.com/@TheSEICMU/) - vidoes from our experts in Software Engineering.
16+
* [Podcasts](https://insights.sei.cmu.edu/podcasts/) - podcasts from our experts in Software Engineering.
17+
* [GitHub](https://github.com/cmu-sei) - view the source for all of our repositories.
18+
* [Flow Tools](https://tools.netsa.cert.org/) - documentation and source for all our flow collection and analysis tools.
19+
20+
# [certcc/fixbuf](https://tools.netsa.cert.org/fixbuf2/index.html)
21+
22+
23+
[![CI](https://img.shields.io/github/actions/workflow/status/cmu-sei/docker-fixbuf/release.yml?style=for-the-badge&logo=github)](https://github.com/cmu-sei/docker-fixbuf/actions?query=workflow%3ARelease) [![Docker pulls](https://img.shields.io/docker/pulls/cmusei/fixbuf?color=468f8b&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/cmusei/fixbuf/)
24+
25+
[libfixbuf](https://tools.netsa.cert.org/fixbuf2/index.html) is a compliant implementation of the IPFIX Protocol, as defined in the "Specification of the IPFIX Protocol for the Exchange of Flow Information" (RFC 7011). It supports the information model defined in "Information Model for IP Flow Information Export" (RFC 7012), extended as proposed by "Bidirectional Flow Export using IPFIX" (RFC 5103) to support information elements for representing biflows. libfixbuf supports structured data elements as described in "Export of Structured Data in IPFIX" (RFC 6313), which adds the ability to export basicLists, subTemplateLists, and subTemplateMultiLists. libfixbuf can export type information for IPFIX elements as described in "Exporting Type Information for IPFIX Information Elements" (RFC 5610), and it supports reading this information.
26+
27+
## Documentation
28+
29+
More information [here](https://tools.netsa.cert.org/fixbuf2/libfixbuf/index.html).
30+
31+
## Usage
32+
33+
The intention of this container is to be used as a base for building other [NetSA tool](https://tools.netsa.cert.org/index.html) container images.
34+
35+
However, [ipfixDump](https://tools.netsa.cert.org/fixbuf2/ipfixDump.html) is included as part of the fixbuf install and can be used to print contents of an IPFIX file as human-readable text. For example, the below command mounts the `$PWD/test` folder from the host to `/tmp` in the `fixbuf` container. It contains a yaf produced ipfix file named `flows.yaf-20231026175944-00000.yaf`, that we use ipfixDump to produce stats for:
36+
37+
```bash
38+
docker run --rm -it -v $PWD/test:/tmp \
39+
cmusei/fixbuf:latest \
40+
ipfixDump \
41+
--in /tmp/flows.yaf-20231026175944-00000.yaf \
42+
--stats \
43+
--yaf
44+
```
45+
```
46+
*** File Stats: 2 Messages, 9 Data Records, 43 Template Records ***
47+
Template ID | Records
48+
45873 (0xb331)| 9
49+
49155 (0xc003)| 0
50+
49156 (0xc004)| 0
51+
49157 (0xc005)| 0
52+
49160 (0xc008)| 0
53+
49161 (0xc009)| 0
54+
49171 (0xc013)| 0
55+
49173 (0xc015)| 0
56+
49176 (0xc018)| 0
57+
49664 (0xc200)| 0
58+
49670 (0xc206)| 0
59+
49920 (0xc300)| 0
60+
50176 (0xc400)| 0
61+
50432 (0xc500)| 0
62+
50688 (0xc600)| 0
63+
50944 (0xc700)| 0
64+
51200 (0xc800)| 0
65+
51456 (0xc900)| 0
66+
51712 (0xca00)| 0
67+
51722 (0xca0a)| 4
68+
51723 (0xca0b)| 4
69+
51969 (0xcb01)| 0
70+
51970 (0xcb02)| 0
71+
51971 (0xcb03)| 0
72+
52224 (0xcc00)| 1
73+
52480 (0xcd00)| 0
74+
52736 (0xce00)| 0
75+
52737 (0xce01)| 0
76+
52738 (0xce02)| 0
77+
52739 (0xce03)| 0
78+
52740 (0xce04)| 0
79+
52741 (0xce05)| 0
80+
52742 (0xce06)| 0
81+
52743 (0xce07)| 0
82+
52744 (0xce08)| 0
83+
52745 (0xce09)| 0
84+
52748 (0xce0c)| 0
85+
52749 (0xce0d)| 0
86+
52756 (0xce14)| 0
87+
52992 (0xcf00)| 0
88+
53251 (0xd003)| 0
89+
53252 (0xd004)| 0
90+
53253 (0xd005)| 0
91+
```
92+
93+
Version 3+ of the fixbuf container contains the [ipfix2json](https://tools.netsa.cert.org/fixbuf/ipfix2json.html) tool, which can be used to print contents of an IPFIX file as json text. For example, using the same IPFIX input file from above `flows.yaf-20231026175944-00000.yaf`:
94+
95+
```bash
96+
docker run --rm -it -v $PWD/test:/tmp \
97+
cmusei/fixbuf:3 \
98+
ipfix2json \
99+
--in /tmp/flows.yaf-20231026175944-00000.yaf \
100+
--out -
101+
```
102+
```
103+
{"template_record:0xd005()":["certToolId","observationTimeSeconds"]}
104+
{"template_record:0xc003()":["tcpSequenceNumber","initialTCPFlags","unionTCPFlags"]}
105+
{"template_record:0xce07()":["dnsTXTData"]}
106+
{"template_record:0xc009()":["mptcpInitialDataSequenceNumber","mptcpReceiverToken","mptcpMaximumSegmentSize","mptcpAddressId","mptcpFlags"]}
107+
{"template_record:0xca00()":["basicList","basicList","basicList","basicList","basicList","basicList","basicList"]}
108+
{"template_record:0xc400()":["tftpFilename","tftpMode"]}
109+
{"template_record:0xce02()":["sourceIPv6Address"]}
110+
{"template_record:0xce0d()":["mysqlCommandText","mysqlCommandCode","paddingOctets"]}
111+
{"template_record:0xc004()":["sourceMacAddress","destinationMacAddress"]}
112+
{"template_record:0xce08()":["dnsSRVTarget","dnsSRVPriority","dnsSRVWeight","dnsSRVPort","paddingOctets"]}
113+
{"template_record:0xc015()":["dataByteCount","averageInterarrivalTime","standardDeviationInterarrivalTime","tcpUrgTotalCount","smallPacketCount","nonEmptyPacketCount","largePacketCount","firstNonEmptyPacketSize","maxPacketSize","standardDeviationPayloadLength","firstEightNonEmptyPacketDirections","paddingOctets","reverseDataByteCount","reverseAverageInterarrivalTime","reverseStandardDeviationInterarrivalTime","reverseTcpUrgTotalCount","reverseSmallPacketCount","reverseNonEmptyPacketCount","reverseLargePacketCount","reverseFirstNonEmptyPacketSize","reverseMaxPacketSize","reverseStandardDeviationPayloadLength","paddingOctets"]}
114+
snip...
115+
```

tests/default/test_default.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def test_fixbuf_version(host):
2+
version = "2.5.0"
3+
command = """PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/netsa/lib/pkgconfig \
4+
pkg-config --modversion libfixbuf"""
5+
6+
cmd = host.run(command)
7+
8+
assert version in cmd.stdout

0 commit comments

Comments
 (0)