Skip to content

Commit

Permalink
Adding automated CI testing via Github Actions (thinkst#175)
Browse files Browse the repository at this point in the history
* Adds automated CI tests via Github Actions

* Updates Jinja2 for python 3.10

* Fixes tests

* Disables fail-fast so all parallel jobs complete
  • Loading branch information
joewesch committed Jun 23, 2022
1 parent 2e364a4 commit 3b6f7d4
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 5 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/opencanary_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: OpenCanary Tests

on:
- "push"
- "pull_request"

jobs:
opencanary_tests:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: ["ubuntu-18.04", "ubuntu-20.04", "macos-10.15", "macos-11"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python-version }}"
- name: Install required linux dependencies
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install python3-setuptools
- name: Install wheel
run: sudo pip3 install wheel
- name: Create package
run: sudo python3 setup.py sdist
- name: Install package
run: sudo pip3 install dist/opencanary-*.tar.gz
- name: Install test dependencies
run: sudo pip3 install -r opencanary/test/requirements.txt
- name: Copy config file
run: cp opencanary/test/opencanary.conf .
- name: Start OpenCanary
run: opencanaryd --start
- name: Run Pytest
run: pytest -s
6 changes: 3 additions & 3 deletions opencanary/test/module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_log_git_clone(self):
# This test must be run after the test_clone_a_repository.
# Unless we add an attempt to clone into this test, or the setup.
last_log = get_last_log()
self.assertEqual(last_log['logdata']['HOST'], "localhost")
self.assertIn("localhost", last_log['logdata']['HOST'])
self.assertEqual(last_log['logdata']['REPO'], "test.git")


Expand Down Expand Up @@ -206,11 +206,11 @@ def test_ssh_with_basic_login(self):
self.assertRaises(paramiko.ssh_exception.AuthenticationException,
self.connection.connect,
hostname="localhost",
port=22,
port=2222,
username="test_user",
password="test_pass")
last_log = get_last_log()
self.assertEqual(last_log['dst_port'], 22)
self.assertEqual(last_log['dst_port'], 2222)
self.assertIn('paramiko', last_log['logdata']['REMOTEVERSION'])
self.assertEqual(last_log['logdata']['USERNAME'], "test_user")
self.assertEqual(last_log['logdata']['PASSWORD'], "test_pass")
Expand Down
116 changes: 116 additions & 0 deletions opencanary/test/opencanary.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"device.node_id": "opencanary-1",
"ip.ignorelist": [ ],
"git.enabled": true,
"git.port" : 9418,
"ftp.enabled": true,
"ftp.port": 21,
"ftp.banner": "FTP server ready",
"http.banner": "Apache/2.2.22 (Ubuntu)",
"http.enabled": true,
"http.port": 80,
"http.skin": "nasLogin",
"http.skin.list": [
{
"desc": "Plain HTML Login",
"name": "basicLogin"
},
{
"desc": "Synology NAS Login",
"name": "nasLogin"
}
],
"httpproxy.enabled" : false,
"httpproxy.port": 8080,
"httpproxy.skin": "squid",
"httproxy.skin.list": [
{
"desc": "Squid",
"name": "squid"
},
{
"desc": "Microsoft ISA Server Web Proxy",
"name": "ms-isa"
}
],
"logger": {
"class": "PyLogger",
"kwargs": {
"formatters": {
"plain": {
"format": "%(message)s"
},
"syslog_rfc": {
"format": "opencanaryd[%(process)-5s:%(thread)d]: %(name)s %(levelname)-5s %(message)s"
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout"
},
"file": {
"class": "logging.FileHandler",
"filename": "/var/tmp/opencanary.log"
}
}
}
},
"portscan.enabled": false,
"portscan.ignore_localhost": false,
"portscan.logfile":"/var/log/kern.log",
"portscan.synrate": 5,
"portscan.nmaposrate": 5,
"portscan.lorate": 3,
"smb.auditfile": "/var/log/samba-audit.log",
"smb.enabled": false,
"mysql.enabled": true,
"mysql.port": 3306,
"mysql.banner": "5.5.43-0ubuntu0.14.04.1",
"ssh.enabled": true,
"ssh.port": 2222,
"ssh.version": "SSH-2.0-OpenSSH_5.1p1 Debian-4",
"redis.enabled": false,
"redis.port": 6379,
"rdp.enabled": false,
"rdp.port": 3389,
"sip.enabled": false,
"sip.port": 5060,
"snmp.enabled": false,
"snmp.port": 161,
"ntp.enabled": true,
"ntp.port": 123,
"tftp.enabled": false,
"tftp.port": 69,
"tcpbanner.maxnum":10,
"tcpbanner.enabled": false,
"tcpbanner_1.enabled": false,
"tcpbanner_1.port": 8001,
"tcpbanner_1.datareceivedbanner": "",
"tcpbanner_1.initbanner": "",
"tcpbanner_1.alertstring.enabled": false,
"tcpbanner_1.alertstring": "",
"tcpbanner_1.keep_alive.enabled": false,
"tcpbanner_1.keep_alive_secret": "",
"tcpbanner_1.keep_alive_probes": 11,
"tcpbanner_1.keep_alive_interval":300,
"tcpbanner_1.keep_alive_idle": 300,
"telnet.enabled": false,
"telnet.port": 23,
"telnet.banner": "",
"telnet.honeycreds": [
{
"username": "admin",
"password": "$pbkdf2-sha512$19000$bG1NaY3xvjdGyBlj7N37Xw$dGrmBqqWa1okTCpN3QEmeo9j5DuV2u1EuVFD8Di0GxNiM64To5O/Y66f7UASvnQr8.LCzqTm6awC8Kj/aGKvwA"
},
{
"username": "admin",
"password": "admin1"
}
],
"mssql.enabled": false,
"mssql.version": "2012",
"mssql.port":1433,
"vnc.enabled": false,
"vnc.port":5000
}
3 changes: 2 additions & 1 deletion opencanary/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
requests
paramiko
PyMySQL
gitpython
gitpython
pytest
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_version(rel_path):
'PyPDF2==1.26.0',
'fpdf==1.7.2',
'passlib==1.7.1',
'Jinja2==2.10.1',
'Jinja2==3.0.1',
'ntlmlib==0.72',
'bcrypt==3.1.7',
'setuptools==44.0.0',
Expand Down

0 comments on commit 3b6f7d4

Please sign in to comment.