-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from cmu-sei/Welder-Release
Initial Commit of Welder
- Loading branch information
Showing
8 changed files
with
920 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
*.xml | ||
*.iml |
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,18 @@ | ||
FROM python:3.7 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y vim | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY welder . | ||
|
||
ENV FLASK_APP=welder.py | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
EXPOSE 5000 | ||
|
||
CMD [ "flask", "run", "--host=0.0.0.0"] |
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,21 @@ | ||
{ | ||
"view": [{ | ||
"name": "View Name", | ||
"teams": [ | ||
{ | ||
"name": "Team Name", | ||
"templates": ["VM Workstation Template Path"], | ||
"cluster": "Target vCenter cluster", | ||
"users": [ | ||
{ | ||
"name": "User Name", | ||
"templates": ["VM Workstation Template Path"], | ||
"cluster": "Target vCenter cluster" | ||
} | ||
] | ||
} | ||
], | ||
"templates": ["VM Workstation Template Path"], | ||
"cluster": "Target vCenter cluster" | ||
}] | ||
} |
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,19 @@ | ||
certifi==2019.3.9 | ||
chardet==3.0.4 | ||
Click==7.0 | ||
ecdsa==0.13.1 | ||
Flask==1.0.2 | ||
Flask-Cors==3.0.7 | ||
future==0.17.1 | ||
idna==2.8 | ||
itsdangerous==1.1.0 | ||
Jinja2==2.10.1 | ||
MarkupSafe==1.1.1 | ||
pyasn1==0.4.5 | ||
python-jose==3.0.1 | ||
pyvmomi==6.7.1.2018.12 | ||
requests==2.21.0 | ||
rsa==4.0 | ||
six==1.12.0 | ||
urllib3==1.24.2 | ||
Werkzeug==0.15.2 |
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,11 @@ | ||
""" | ||
Crucible | ||
Copyright 2020 Carnegie Mellon University. | ||
NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. | ||
Released under a MIT (SEI)-style license, please see license.txt or contact [email protected] for full terms. | ||
[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution. Please see Copyright notice for non-US Government use and distribution. | ||
Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark Office by Carnegie Mellon University. | ||
DM20-0181 | ||
""" | ||
|
||
|
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,63 @@ | ||
""" | ||
Crucible | ||
Copyright 2020 Carnegie Mellon University. | ||
NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. | ||
Released under a MIT (SEI)-style license, please see license.txt or contact [email protected] for full terms. | ||
[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution. Please see Copyright notice for non-US Government use and distribution. | ||
Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark Office by Carnegie Mellon University. | ||
DM20-0181 | ||
""" | ||
|
||
import requests | ||
import threading | ||
import time | ||
|
||
|
||
THREADS = 200 | ||
REQ_PER_THREAD = 100 | ||
|
||
|
||
def request_thread(token): | ||
headers = {'Authorization': f'Bearer {token}'} | ||
for i in range(REQ_PER_THREAD): | ||
r = requests.post('http://localhost:5000/api/Welder%20Test%20View', headers=headers) | ||
if r.status_code != 200: | ||
print(f'Got code {r.status_code}') | ||
|
||
|
||
def main(): | ||
token_data = { | ||
'grant_type': 'password', | ||
'username': '[email protected]', | ||
'password': 'ChangeMe321!', | ||
'scope': 's3', | ||
} | ||
|
||
token_response = requests.post( | ||
'http://localhost:10000/connect/token', | ||
data=token_data, | ||
auth=('welder', 'a') | ||
) | ||
if not token_response.status_code == 200: | ||
raise Exception('Got a bad token response.') | ||
else: | ||
print(token_response.json()) | ||
|
||
token = token_response.json()['access_token'] | ||
|
||
start = time.time() | ||
pool = [] | ||
for i in range(THREADS): | ||
t = threading.Thread(target=request_thread, args=(token,)) | ||
t.start() | ||
pool.append(t) | ||
|
||
for t in pool: | ||
t.join() | ||
|
||
print(f'With {THREADS} threads and {REQ_PER_THREAD} requests per thread, took {time.time() - start}') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|
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,21 @@ | ||
{ | ||
"view": [{ | ||
"name": "Welder Test View", | ||
"teams": [ | ||
{ | ||
"name": "Admin", | ||
"templates": ["ScrapMetal"], | ||
"cluster": "Gamespace", | ||
"users": [ | ||
{ | ||
"name": "Administrator", | ||
"templates": ["ScrapMetal2"], | ||
"cluster": "Gamespace" | ||
} | ||
] | ||
} | ||
], | ||
"templates": ["ScrapMetal3"], | ||
"cluster": "Gamespace" | ||
}] | ||
} |
Oops, something went wrong.