Skip to content

Commit

Permalink
Merge pull request #23 from cmu-sei/Welder-Release
Browse files Browse the repository at this point in the history
Initial Commit of Welder
  • Loading branch information
sei-ebram authored Jun 19, 2020
2 parents 19a85d5 + 9acef9e commit 743970d
Show file tree
Hide file tree
Showing 8 changed files with 920 additions and 0 deletions.
109 changes: 109 additions & 0 deletions welder/.gitignore
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
18 changes: 18 additions & 0 deletions welder/Dockerfile
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"]
21 changes: 21 additions & 0 deletions welder/JSONexample
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"
}]
}
19 changes: 19 additions & 0 deletions welder/requirements.txt
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
11 changes: 11 additions & 0 deletions welder/welder/__init__.py
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
"""


63 changes: 63 additions & 0 deletions welder/welder/loadtest.py
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()

21 changes: 21 additions & 0 deletions welder/welder/welder.json
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"
}]
}
Loading

0 comments on commit 743970d

Please sign in to comment.