Skip to content

Commit 7aa90b7

Browse files
authored
New release 0.1.0 (#197)
1 parent 8cd204b commit 7aa90b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2120
-296
lines changed

.circleci/config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Python CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-python/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
- image: circleci/python:3.6.1
10+
11+
# Specify service dependencies here if necessary
12+
# CircleCI maintains a library of pre-built images
13+
# documented at https://circleci.com/docs/2.0/circleci-images/
14+
# - image: circleci/postgres:9.4
15+
16+
working_directory: ~/repo
17+
18+
steps:
19+
- checkout
20+
21+
# Download and cache dependencies
22+
- restore_cache:
23+
keys:
24+
- v1-dependencies-{{ checksum "requirements.txt" }}
25+
# fallback to using the latest cache if no exact match is found
26+
- v1-dependencies-
27+
28+
- run:
29+
name: install dependencies
30+
command: |
31+
python3 -m venv venv
32+
. venv/bin/activate
33+
pip install -r requirements.txt
34+
35+
- save_cache:
36+
paths:
37+
- ./venv
38+
key: v1-dependencies-{{ checksum "requirements.txt" }}
39+
40+
- run:
41+
name: run tests
42+
command: |
43+
. venv/bin/activate
44+
python runtests.py
45+
46+
- run:
47+
name: lint
48+
command: |
49+
. venv/bin/activate
50+
pylint **/*.py -E
51+
pylint **/*.py --exit-zero
52+
53+
- store_artifacts:
54+
path: test-reports
55+
destination: test-reports

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
.venv

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.pyc
22
config.json
3+
config_savelink.json
34
config_solvetracker.json
45
*.bin
56
*.log

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
All notable changes to this project will be kept in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/).
6+
7+
## [0.1.0] - 2019-09-10
8+
Initial release

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
FROM python:3
22

3-
# Bundle app source
4-
COPY . /src/
5-
WORKDIR /src/
3+
WORKDIR /src
4+
5+
# Copy requirements
6+
COPY ./requirements.txt /src
67

78
# Install requirements
89
RUN pip install --no-cache-dir -r requirements.txt
910

11+
# Copy rest of source
12+
COPY . /src
13+
1014
CMD ["python", "run.py"]

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
PWD = $(shell pwd)
22

3-
image:
3+
build:
44
docker build . -t otabot
55

6-
lint:
6+
image:
7+
docker images | grep otabot || docker build . -t otabot
8+
9+
lint: image
710
docker run --rm -v ${PWD}/:/src/ otabot pylint **/*.py -E
811

9-
run: image
12+
checklint: image
13+
docker run --rm -v ${PWD}/:/src/ otabot pylint **/*.py --exit-zero
14+
15+
run: build
1016
docker run --rm -it otabot
1117

12-
runlocal:
18+
runlocal: image
1319
docker run --rm -it -v ${PWD}/:/src/ otabot
20+
21+
test:
22+
docker run --rm -v ${PWD}/:/src/ otabot python3 runtests.py
23+
24+
background: image
25+
docker run --rm -d --name otabot otabot
26+
27+
stop:
28+
docker stop otabot

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,48 @@ Example:
108108
3. Update the templates in `templates` according to your preferences (or go with the default ones).
109109
4. Make sure that there's a `_posts` and `_stats` folder in your git repository.
110110
4. You should be good to go now and git support should be active on the next startup. You can now use the `postsolves` command to push blog posts with the current solve status to git.
111+
112+
113+
## Using Link saver
114+
115+
1. Setup a github repo with jekyll and staticman (e.g. https://github.com/ujjwal96/links).
116+
2. Copy `config_savelink.json.template` to `config_savelink.json`.
117+
3. Configure the git repo and branch to be used.
118+
4. Add the decrypted staticman-token used in `staticman.yml` in the config.
119+
5. Add a link to your repo, so people can look it up via `showlinkurl`
120+
121+
Example:
122+
```
123+
{
124+
"git_repo": "reponame/links",
125+
"git_branch": "gh-pages",
126+
"staticman-token": "9d837771-945a-489d-cd80-13abcdefa112",
127+
"allowed_users": [],
128+
"repo_link_url": "https://reponame.github.io/links/"
129+
}
130+
```
131+
132+
## Archive reminder
133+
134+
To enable archive reminders set an offset (in hours) in `config.json` for `archive_ctf_reminder_offset`. Clear or remove the setting to disable reminder handling.
135+
136+
If active, the bot will create a reminder for every bot admin on `!endctf` to inform him, when the ctf was finished for the specified time and it should be archived.
137+
138+
Example (for being reminded one week after the ctf has finished):
139+
```
140+
{
141+
...
142+
"archive_ctf_reminder_offset" : "168"
143+
}
144+
```
145+
146+
## Log command deletion
147+
148+
To enable logging of deleting messages containing specific keywords, set `delete_watch_keywords` in `config.json` to a comma separated list of keywords.
149+
Clear or remove the setting to disable deletion logging.
150+
151+
Example
152+
```
153+
{
154+
"delete_watch_keywords" : "workon, reload, endctf"
155+
}

addons/syscalls/syscallinfo.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, filename):
1111

1212
self.parse_table(filename)
1313

14-
def getEntryDict(self, parts, identifiers):
14+
def get_entry_dict(self, parts, identifiers):
1515
entry = collections.OrderedDict()
1616

1717
for i in range(len(parts)):
@@ -33,23 +33,20 @@ def parse_table(self, filename):
3333

3434
for line in lines[1:]:
3535
parts = line.split("\t")
36-
self.entries[parts[1]] = self.getEntryDict(
36+
self.entries[parts[1]] = self.get_entry_dict(
3737
line.split("\t"), identifiers)
3838

39-
def getEntryByID(self, idx):
39+
def get_entry_by_id(self, idx):
4040
for entry in self.entries:
4141
if self.entries[entry]["#"] == str(idx):
4242
return self.entries[entry]
4343

4444
return None
4545

46-
def getEntryByName(self, name):
47-
if name in self.entries:
48-
return self.entries[name]
46+
def get_entry_by_name(self, name):
47+
return self.entries.get(name)
4948

50-
return None
51-
52-
def getInfoMessage(self, entry):
49+
def get_info_message(self, entry):
5350
if entry:
5451
msg = ""
5552

@@ -60,13 +57,13 @@ def getInfoMessage(self, entry):
6057

6158
return None
6259

63-
def getInfoMessageByID(self, idx):
64-
entry = self.getEntryByID(idx)
65-
return self.getInfoMessage(entry)
60+
def get_info_message_by_id(self, idx):
61+
entry = self.get_entry_by_id(idx)
62+
return self.get_info_message(entry)
6663

67-
def getInfoMessageByName(self, name):
68-
entry = self.getEntryByName(name)
69-
return self.getInfoMessage(entry)
64+
def get_info_message_by_name(self, name):
65+
entry = self.get_entry_by_name(name)
66+
return self.get_info_message(entry)
7067

7168

7269
class SyscallInfo:
@@ -79,10 +76,10 @@ def __init__(self, basedir):
7976

8077
self.tables[table] = SyscallTable(filename)
8178

82-
def getAvailableArchitectures(self):
79+
def get_available_architectures(self):
8380
return self.tables.keys()
8481

85-
def getArch(self, arch):
82+
def get_arch(self, arch):
8683
if arch in self.tables:
8784
return self.tables[arch]
8885

bottypes/challenge.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ class Challenge:
55
def __init__(self, ctf_channel_id, channel_id, name, category):
66
"""
77
An object representation of an ongoing challenge.
8+
ctf_channel_id : The slack id for the associated parent ctf channel
89
channel_id : The slack id for the associated channel
910
name : The name of the challenge
11+
category : The category of the challenge
1012
"""
1113

1214
self.channel_id = channel_id

bottypes/command.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from abc import ABC, abstractmethod
1+
from abc import ABC
22

33

44
class Command(ABC):
55
"""Defines the command interface."""
66

7-
def __init__(self): pass
7+
def __init__(self):
8+
pass
89

910
@classmethod
10-
def execute(cls, slack_client, args, channel_id, user, user_is_admin): pass
11+
def execute(cls, slack_wrapper, args, timestamp, channel_id, user_id, user_is_admin):
12+
pass

0 commit comments

Comments
 (0)