Auto-generate secret key and fixing challenge modal

selenium-screenshot-testing
CodeKevin 2015-11-17 19:46:44 -05:00
parent e659775e0d
commit 81345dc6d2
6 changed files with 16 additions and 92 deletions

3
.gitignore vendored
View File

@ -56,4 +56,5 @@ target/
*.db *.db
*.log *.log
.idea/ .idea/
static/uploads CTFd/static/uploads
.ctfd_secret_key

View File

@ -1,6 +1,16 @@
import os import os
##### GENERATE SECRET KEY #####
with open('.ctfd_secret_key', 'a+') as secret:
secret.seek(0) # Seek to beginning of file since a+ mode leaves you at the end and w+ deletes the file
key = secret.read()
if not key:
key = os.urandom(64)
secret.write(key)
secret.flush()
##### SERVER SETTINGS ##### ##### SERVER SETTINGS #####
SECRET_KEY = os.urandom(64) SECRET_KEY = key
SQLALCHEMY_DATABASE_URI = 'sqlite:///ctfd.db' SQLALCHEMY_DATABASE_URI = 'sqlite:///ctfd.db'
SESSION_TYPE = "filesystem" SESSION_TYPE = "filesystem"
SESSION_FILE_DIR = "/tmp/flask_session" SESSION_FILE_DIR = "/tmp/flask_session"

View File

@ -27,6 +27,7 @@ function loadchal(id) {
obj = $.grep(challenges['game'], function (e) { obj = $.grep(challenges['game'], function (e) {
return e.id == id; return e.id == id;
})[0] })[0]
$('a[href=#desc-write]').click() // Switch to Write tab
$('.chal-title').text(obj.name); $('.chal-title').text(obj.name);
$('.chal-name').val(obj.name); $('.chal-name').val(obj.name);
$('.chal-desc').val(obj.description); $('.chal-desc').val(obj.description);

View File

@ -49,7 +49,7 @@
<div class="row"> <div class="row">
<input id="prevent_name_change" name="prevent_name_change" type="checkbox" {% if prevent_name_change %}checked{% endif %}> <input id="prevent_name_change" name="prevent_name_change" type="checkbox" {% if prevent_name_change %}checked{% endif %}>
<label for="prevent_name_change">Prevent Team Name Changes</label> <label for="prevent_name_change">Prevent team name changes</label>
</div> </div>
<button class="radius" type='submit'>Update</button> <button class="radius" type='submit'>Update</button>

View File

@ -1,88 +0,0 @@
#submit-key{
display: none;
}
#chal > h1{
text-align: center
}
#chal > form{
width: 400px;
margin: 0 auto;
}
#chal > form > h3,h4{
text-align: center;
}
#chal > form > input{
display: none;
}
table{
width: 100%;
}
/*Not sure why foundation needs these two...*/
.top-bar input{
height: auto;
padding-top: 0.35rem;
padding-bottom: 0.35rem;
font-size: 0.75rem;
}
.top-bar .button{
padding-top: 0.45rem;
padding-bottom: 0.35rem;
margin-bottom: 0;
font-size: 0.75rem;
}
.dropdown{
background-color: #333 !important;
padding: 5px;
}
.dropdown button{
padding-top: 0.45rem;
padding-bottom: 0.35rem;
margin-bottom: 0;
font-size: 0.75rem;
}
#challenges button{
margin: 5px;
}
.row h1{
text-align: center;
}
.textbox{
height: 150px;
}
.chal-tag{
margin: 0 5px 0 5px;
}
#score-graph{
max-height: 400px;
}
#keys-pie-graph{
width: 400px;
max-height: 330px;
float: left;
}
#categories-pie-graph{
width: 600px;
float: left;
max-height: 330px;
}
#admin-pages-editor{
width: 100%;
}

View File

@ -5,5 +5,5 @@ RUN apt-get install git gunicorn -y
RUN git clone https://github.com/isislab/CTFd.git /opt/CTFd && cd /opt/CTFd && ./prepare.sh RUN git clone https://github.com/isislab/CTFd.git /opt/CTFd && cd /opt/CTFd && ./prepare.sh
WORKDIR /opt/CTFd WORKDIR /opt/CTFd
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "-w", "1", "CTFd:create_app()"] CMD ["gunicorn", "--bind", "0.0.0.0:8000", "-w", "4", "CTFd:create_app()"]
EXPOSE 8000 EXPOSE 8000