Skip to content

Commit fdd8b56

Browse files
authored
Merge pull request #32 from mmguero-dev/develop
v3.0.5 updates, adapt scripts to run with th either docker or podman
2 parents 6089942 + 8633697 commit fdd8b56

16 files changed

+56
-36
lines changed

.github/workflows/navv-build-push-ghcr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
password: ${{ secrets.GITHUB_TOKEN }}
4141
-
4242
name: Build and push
43-
uses: docker/build-push-action@v3
43+
uses: docker/build-push-action@v4
4444
with:
4545
context: .
4646
file: ./docker/Dockerfile

.github/workflows/publish-to-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Set up Python 3.10
15-
uses: actions/setup-python@v4.3.0
15+
uses: actions/setup-python@v4.5.0
1616
with:
1717
python-version: "3.10"
1818
- name: Install pypa/build

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
© 2021 Battelle Energy Alliance, LLC
3+
© 2023 Battelle Energy Alliance, LLC
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Github cisagov/network-architecture-verification-and-validation
33
Licensed under BSD-3 License.
44

55

6-
© 2021 Battelle Energy Alliance, LLC
6+
© 2023 Battelle Energy Alliance, LLC
77
ALL RIGHTS RESERVED
88

99
Prepared by Battelle Energy Alliance, LLC

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ See [`docker/README.md`](./docker/README.md) for setup and instructions for runn
255255

256256
## <a name="Footer"></a>Copyright
257257

258-
[NAVV](https://github.com/cisagov/network-architecture-verification-and-validation) is Copyright 2021 Battelle Energy Alliance, LLC, licensed under the BSD-3 Clause License.
258+
[NAVV](https://github.com/cisagov/network-architecture-verification-and-validation) is Copyright 2023 Battelle Energy Alliance, LLC, licensed under the BSD-3 Clause License.
259259

260260
See [`LICENSE`](./LICENSE) for the terms of its release.
261261

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM ubuntu:22.04
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
LABEL maintainer="[email protected]"
66
LABEL org.opencontainers.image.authors='[email protected]'

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ total 9.4M
104104
```
105105
## <a name="Footer"></a>Copyright
106106

107-
[NAVV](https://github.com/cisagov/network-architecture-verification-and-validation) is Copyright 2021 Battelle Energy Alliance, LLC, licensed under the BSD-3 Clause License.
107+
[NAVV](https://github.com/cisagov/network-architecture-verification-and-validation) is Copyright 2023 Battelle Energy Alliance, LLC, licensed under the BSD-3 Clause License.
108108

109109
See [`LICENSE`](./LICENSE) for the terms of its release.

docker/backup_docker.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
set -e
66
set -o pipefail
77
set -u
88

99
ENCODING="utf-8"
1010

11+
# image name (can be overriden via NAVV_DOCKER_IMAGE env. var.)
12+
NAVV_DOCKER_IMAGE="${NAVV_DOCKER_IMAGE:-ghcr.io/cisagov/network-architecture-verification-and-validation:latest}"
13+
# container engine (docker vs. podman, can be overriden via CONTAINER_ENGINE env. var.)
14+
CONTAINER_ENGINE="${CONTAINER_ENGINE:-docker}"
15+
1116
[[ "$(uname -s)" = 'Darwin' ]] && REALPATH=grealpath || REALPATH=realpath
1217
[[ "$(uname -s)" = 'Darwin' ]] && DIRNAME=gdirname || DIRNAME=dirname
13-
if ! (type "$REALPATH" && type "$DIRNAME" && type docker) > /dev/null; then
14-
echo "$(basename "${BASH_SOURCE[0]}") requires docker, $REALPATH and $DIRNAME"
18+
if ! (type "$REALPATH" && type "$DIRNAME" && type "$CONTAINER_ENGINE") > /dev/null; then
19+
echo "$(basename "${BASH_SOURCE[0]}") requires $CONTAINER_ENGINE, $REALPATH and $DIRNAME"
1520
exit 1
1621
fi
1722
export SCRIPT_PATH="$($DIRNAME $($REALPATH -e "${BASH_SOURCE[0]}"))"
1823

19-
# default docker image name (can be overriden via NAVV_DOCKER_IMAGE env. var.)
20-
NAVV_DOCKER_IMAGE="${NAVV_DOCKER_IMAGE:-ghcr.io/cisagov/network-architecture-verification-and-validation:latest}"
21-
2224
# save tarball with image creation date and sha
23-
DOCKER_BACKUP_FILENAME=navv-docker_$(date -d "$(docker inspect --format='{{.Created}}' "$NAVV_DOCKER_IMAGE")" +"%Y%m%d_%H%M%S")_$(docker images --no-trunc --quiet "$NAVV_DOCKER_IMAGE" | cut -d: -f2 | cut -c 1-12).tar.gz
25+
DOCKER_BACKUP_FILENAME=navv-$CONTAINER_ENGINE-$(date -d "$($CONTAINER_ENGINE inspect --format='{{.Created}}' "$NAVV_DOCKER_IMAGE" | sed "s/ /T/" | sed "s/ +0000 UTC/Z/")" +"%Y%m%d_%H%M%S")_$($CONTAINER_ENGINE images --no-trunc --quiet "$NAVV_DOCKER_IMAGE" | cut -d: -f2 | cut -c 1-12).tar.gz
2426

25-
# backup docker image and navv-docker.sh
26-
docker save "$NAVV_DOCKER_IMAGE" | gzip > "$DOCKER_BACKUP_FILENAME"
27+
# backup image and navv-docker.sh
28+
if [[ "$CONTAINER_ENGINE" == "podman" ]]; then
29+
$CONTAINER_ENGINE save --format oci-archive "$NAVV_DOCKER_IMAGE" | gzip > "$DOCKER_BACKUP_FILENAME"
30+
else
31+
$CONTAINER_ENGINE save "$NAVV_DOCKER_IMAGE" | gzip > "$DOCKER_BACKUP_FILENAME"
32+
fi
2733
[[ ! -r navv-docker.sh ]] && cp "$SCRIPT_PATH"/navv-docker.sh ./
2834

2935
echo "Transfer $DOCKER_BACKUP_FILENAME and navv-docker.sh to destination host" | tee ./navv_export.txt
30-
echo "Import $NAVV_DOCKER_IMAGE with docker load -i $DOCKER_BACKUP_FILENAME" | tee -a ./navv_export.txt
36+
echo "Import $NAVV_DOCKER_IMAGE with $CONTAINER_ENGINE load -i $DOCKER_BACKUP_FILENAME" | tee -a ./navv_export.txt
3137
echo "Run with navv-docker.sh" | tee -a ./navv_export.txt

docker/build_docker.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
set -e
66
set -o pipefail
77
set -u
88

99
ENCODING="utf-8"
1010

11+
# image name (can be overriden via NAVV_DOCKER_IMAGE env. var.)
12+
NAVV_DOCKER_IMAGE="${NAVV_DOCKER_IMAGE:-ghcr.io/cisagov/network-architecture-verification-and-validation:latest}"
13+
# container engine (docker vs. podman, can be overriden via CONTAINER_ENGINE env. var.)
14+
CONTAINER_ENGINE="${CONTAINER_ENGINE:-docker}"
15+
1116
[[ "$(uname -s)" = 'Darwin' ]] && REALPATH=grealpath || REALPATH=realpath
1217
[[ "$(uname -s)" = 'Darwin' ]] && DIRNAME=gdirname || DIRNAME=dirname
13-
if ! (type "$REALPATH" && type "$DIRNAME" && type docker) > /dev/null; then
14-
echo "$(basename "${BASH_SOURCE[0]}") requires docker, $REALPATH and $DIRNAME"
18+
if ! (type "$REALPATH" && type "$DIRNAME" && type $CONTAINER_ENGINE) > /dev/null; then
19+
echo "$(basename "${BASH_SOURCE[0]}") requires $CONTAINER_ENGINE, $REALPATH and $DIRNAME"
1520
exit 1
1621
fi
1722
export SCRIPT_PATH="$($DIRNAME $($REALPATH -e "${BASH_SOURCE[0]}"))"
1823

1924
pushd "$SCRIPT_PATH"/.. >/dev/null 2>&1
2025

21-
docker build -f docker/Dockerfile -t ghcr.io/cisagov/network-architecture-verification-and-validation:latest "$@" .
26+
$CONTAINER_ENGINE build -f docker/Dockerfile -t ghcr.io/cisagov/network-architecture-verification-and-validation:latest "$@" .
2227

2328
popd >/dev/null 2>&1

docker/navv-build-for-export.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
set -o pipefail
66
set -u

docker/navv-docker.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
# navv_docker.sh
66
#
@@ -17,20 +17,29 @@ shopt -s nullglob
1717

1818
ENCODING="utf-8"
1919

20-
# default docker image name (can be overriden via NAVV_DOCKER_IMAGE env. var.)
20+
# image name (can be overriden via NAVV_DOCKER_IMAGE env. var.)
2121
NAVV_DOCKER_IMAGE="${NAVV_DOCKER_IMAGE:-ghcr.io/cisagov/network-architecture-verification-and-validation:latest}"
22+
# container engine (docker vs. podman, can be overriden via CONTAINER_ENGINE env. var.)
23+
CONTAINER_ENGINE="${CONTAINER_ENGINE:-docker}"
24+
if [[ "$CONTAINER_ENGINE" == "podman" ]]; then
25+
PUID=0
26+
PGID=0
27+
else
28+
PUID=$(id -u)
29+
PGID=$(id -g)
30+
fi
2231

2332
# run navv -h to get help
2433
function print_usage() {
25-
docker run --rm "$NAVV_DOCKER_IMAGE" -h | sed "s/\(optional arguments\):/\1 (use short option syntax for docker):/" >&2
34+
$CONTAINER_ENGINE run --rm "$NAVV_DOCKER_IMAGE" -h | sed "s/\(options\):/\1 (use short option syntax for $CONTAINER_ENGINE):/" >&2
2635
}
2736

2837
# figure out actual executable names for realpath, dirname and basename
2938
[[ "$(uname -s)" = 'Darwin' ]] && REALPATH=grealpath || REALPATH=realpath
3039
[[ "$(uname -s)" = 'Darwin' ]] && DIRNAME=gdirname || DIRNAME=dirname
3140
[[ "$(uname -s)" = 'Darwin' ]] && BASENAME=gbasename || BASENAME=basename
32-
if ! (type "$REALPATH" && type "$DIRNAME" && type "$BASENAME" && type docker) > /dev/null; then
33-
echo "$(basename "${BASH_SOURCE[0]}") requires $REALPATH, $DIRNAME, $BASENAME and docker"
41+
if ! (type "$REALPATH" && type "$DIRNAME" && type "$BASENAME" && type $CONTAINER_ENGINE) > /dev/null; then
42+
echo "$(basename "${BASH_SOURCE[0]}") requires $REALPATH, $DIRNAME, $BASENAME and $CONTAINER_ENGINE"
3443
exit 1
3544
fi
3645

@@ -51,7 +60,7 @@ while getopts 'vxeho:p:z:' OPTION; do
5160

5261
# show version and exit
5362
v)
54-
docker run --rm \
63+
$CONTAINER_ENGINE run --rm \
5564
-e PUID=$(id -u) -e PGID=$(id -g) \
5665
"$NAVV_DOCKER_IMAGE" --version ACME
5766
exit 0
@@ -171,9 +180,9 @@ elif [[ -r "$SCRIPT_PATH"/local.zeek ]]; then
171180
MOUNT_ARGS+=( "$SCRIPT_PATH/local.zeek:/opt/zeek/share/zeek/site/local.zeek:ro" )
172181
fi
173182

174-
# run the navv docker image and remove it when it finishes
175-
docker run --rm \
176-
-e PUID=$(id -u) -e PGID=$(id -g) \
183+
# run a navv container and remove it when it finishes
184+
$CONTAINER_ENGINE run --rm \
185+
-e PUID=$PUID -e PGID=$PUID \
177186
-w /output \
178187
"${MOUNT_ARGS[@]}" \
179188
"$NAVV_DOCKER_IMAGE" \

src/navv/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""This file defines the version of this module."""
2-
__version__ = "3.0.4"
2+
__version__ = "3.0.5"

src/navv/data_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
import netaddr
66

src/navv/network_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
# python std library imports
66
import argparse

src/navv/spreadsheet_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
import os
66
import itertools

src/navv/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2021 Battelle Energy Alliance, LLC
3+
# Copyright 2023 Battelle Energy Alliance, LLC
44

55
import os
66
import contextlib

0 commit comments

Comments
 (0)