This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functional verification for SNMPv3 with MD5/DES
https://vaporio.atlassian.net/browse/VIO-1919 This already worked, here is functional verification. This PR also fixes the tests in CI which were silently not running and therefore false passing. That looks like it was broken months ago. See this run: https://build.vio.sh/blue/organizations/jenkins/vapor-ware%2Fsynse-snmp-plugin/detail/craig-VIO-1911-7/7/pipeline/113 Click on Integration Test Expand make integration-test Result: + make integration-test make: Nothing to be done for 'integration-test'. Meaning: Tests were not running in CI. This PR requires: https://github.com/vapor-ware/ci-shared/pull/195 vapor-ware/snmp-emulator#6
- Loading branch information
1 parent
dd6cfd2
commit 9658241
Showing
21 changed files
with
716 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
This directory contains what we need to run the SNMP emulator in a container for testing. | ||
This directory contains what we need to run SNMP emulators in containers | ||
for testing. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This directory contains the pxgms ups emulator for the Eaton UPS. The data | ||
file is a snmpwalk from SNMP OID .1.3.6.1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/bash | ||
|
||
# Start the snmp emulator. | ||
# This is intended to be a universal script to this github repo, | ||
# however we cannot do symlinks because docker cannot follow them above the Dockerfile. | ||
|
||
# The snmp emulator cannot run as root. | ||
# Running a python file to load a configuration file will work, | ||
# but then we don't have access to things like snmpsimd.py when we Popen. | ||
# It is not a path issue. | ||
|
||
# Arguments are positional: | ||
|
||
# Required arguements. | ||
DATA_DIRECTORY=$1 # Where SNMP MIB/OID emulated data lives. | ||
NETWORK_PORT=$2 # Here in order to run multiple emulators. | ||
LOG_DIRECTORY=$3 # Ideally an emulator unique name for logs. Useful for debugging. | ||
SNMP_VERSION=$4 # V1, V2c, V3. Only V3 is currently supported. | ||
|
||
# Check required args: | ||
|
||
# Enure DATA_DIRECTORY is set | ||
if [ -z ${DATA_DIRECTORY+x} ]; then | ||
echo "DATA_DIRECTORY is unset"; | ||
exit 1 | ||
else echo "DATA_DIRECTORY is set to '${DATA_DIRECTORY}'"; | ||
fi | ||
|
||
# Enure NETWORK_PORT is set | ||
if [ -z ${NETWORK_PORT+x} ]; then | ||
echo "NETWORK_PORT is unset"; | ||
exit 1 | ||
else echo "NETWORK_PORT is set to '${NETWORK_PORT}'"; | ||
fi | ||
|
||
# Enure LOG_DIRECTORY is set | ||
if [ -z ${LOG_DIRECTORY+x} ]; then | ||
echo "LOG_DIRECTORY is unset"; | ||
exit 1 | ||
else echo "LOG_DIRECTORY is set to '${LOG_DIRECTORY}'"; | ||
fi | ||
|
||
# Enure SNMP_VERSION is set | ||
if [ -z ${SNMP_VERSION+x} ]; then | ||
echo "SNMP_VERSION is unset"; | ||
exit 1 | ||
else echo "SNMP_VERSION is set to '${SNMP_VERSION}'"; | ||
fi | ||
|
||
# Only SNMP V3 is currently suported. | ||
# FUTURE: Support V1 and V2c. | ||
if [[ ${SNMP_VERSION} -ne V3 ]] ; then | ||
echo "SNMP_VERSION [${SNMP_VERSION}] is not V3" | ||
exit 1 | ||
fi | ||
|
||
# Optional arguments, once snmp v1 and v2c are supported. | ||
# Currently these are required as well because we only support: | ||
# V3_SECURITY_LEVEL=authPriv | ||
# V3_AUTHENTICATION_PROTOCOL={SHA | MD5} | ||
# V3_PRIVACY_PROTOCOL={AES | DES} | ||
|
||
V3_SECURITY_LEVEL=$5 | ||
V3_AUTHENTICATION_PROTOCOL=$6 | ||
V3_PRIVACY_PROTOCOL=$7 | ||
|
||
# Enure V3_SECURITY_LEVEL is set | ||
if [ -z ${V3_SECURITY_LEVEL+x} ]; then | ||
echo "V3_SECURITY_LEVEL is unset"; | ||
exit 1 | ||
else echo "V3_SECURITY_LEVEL is set to '${V3_SECURITY_LEVEL}'"; | ||
fi | ||
|
||
# Only auth and privacy are currently supported. | ||
# FUTURE: Support noAuthNoPriv and authNoPriv. | ||
if [[ ${V3_SECURITY_LEVEL} -ne authPriv ]] ; then | ||
echo "V3_SECURITY_LEVEL [${V3_SECURITY_LEVEL}] is not authPriv" | ||
exit 1 | ||
fi | ||
|
||
python `which snmpsimd.py` \ | ||
--data-dir=${DATA_DIRECTORY} \ | ||
--agent-udpv4-endpoint=0.0.0.0:${NETWORK_PORT} \ | ||
--v3-user=simulator \ | ||
--v3-auth-key=auctoritas \ | ||
--v3-auth-proto=${V3_AUTHENTICATION_PROTOCOL} \ | ||
--v3-priv-key=privatus \ | ||
--v3-priv-proto=${V3_PRIVACY_PROTOCOL} \ | ||
2>&1 | tee /logs/${LOG_DIRECTORY} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This is the container running the PXGMS (Eaton) UPS SNMP emulator to test against. | ||
# | ||
# The galaxy ups currently runs against this emulator as well, although ideally it | ||
# would have its own emulator as well. | ||
# | ||
# This emulator runs on port 1024. | ||
snmp-emulator-pxgms-ups: | ||
container_name: snmp-emulator-pxgms-ups | ||
build: . | ||
dockerfile: Dockerfile | ||
# This command will override what is in the dockerfile. | ||
command: ./start_snmp_emulator.sh ./data 1024 snmp-emulator-pxgms-ups.log V3 authPriv SHA AES | ||
ports: | ||
- 1024:1024/udp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Ths dockerfile starts the SNMP emulator for the tripplite ups in a container for testing. | ||
# This emulator runs on port 1025. | ||
FROM vaporio/vapor-endpoint-base-x64:1.0 | ||
|
||
RUN pip install -I \ | ||
snmpsim \ | ||
pysnmp \ | ||
pyasn1 | ||
|
||
# The emulator will not start as root, so we need to add a user. | ||
# As root, the Error message is the following: | ||
# snmp-emulator | ERROR: cant drop priveleges: Must drop priveleges to a non-priveleged user&group (sic) | ||
# Create the user and ${HOME} | ||
RUN groupadd -r docker && useradd -r -g docker snmp | ||
ADD . /home/snmp | ||
|
||
# These SNMP emulator files are specfic to the device being emulated. | ||
# Data are just places in /home/snmp/data on the emulator to keep it simple. | ||
ADD data/public.snmpwalk /home/snmp/data/public.snmpwalk | ||
|
||
# snmpsmi variation modules (like writecache) are getting installed to a location not in the search path, | ||
# so copy where it will be found. | ||
# snmp user owns /home/snmp and /logs. | ||
RUN mkdir -p /home/snmp/.snmpsim/variation && \ | ||
cp /usr/local/snmpsim/variation/* /home/snmp/.snmpsim/variation && \ | ||
chown snmp:docker /home/snmp -R && \ | ||
chown snmp:docker /logs -R | ||
USER snmp | ||
WORKDIR /home/snmp | ||
|
||
# Default emulator port is 1024. Expose it. | ||
EXPOSE 1024/udp | ||
|
||
# data directory (typically /home/snmp/data) | ||
# port (typically 1024 and up) | ||
# log file name (trying to keep these names unique) | ||
# SNMP version (V3) | ||
CMD ["./start_snmp_emulator.sh","./data","1025","snmp-emulator-tripplite-ups.log", "V3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This directory contains the pxgms ups emulator for the Tripplite UPS. The | ||
data file is a snmpwalk from OID .1.3.6.1 |
Oops, something went wrong.