Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joanne Hugé
slapos.toolbox
Commits
c33f0922
Commit
c33f0922
authored
Jan 31, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solve ACE arbitrary file Modification
parent
a71c3189
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
51 deletions
+93
-51
slapos/runner/static/scripts/editor.js
slapos/runner/static/scripts/editor.js
+62
-0
slapos/runner/templates/layout.html
slapos/runner/templates/layout.html
+1
-22
slapos/runner/templates/updateInstanceProfile.html
slapos/runner/templates/updateInstanceProfile.html
+11
-5
slapos/runner/templates/updateSoftwareProfile.html
slapos/runner/templates/updateSoftwareProfile.html
+11
-6
slapos/runner/views.py
slapos/runner/views.py
+8
-18
No files found.
slapos/runner/static/scripts/editor.js
0 → 100644
View file @
c33f0922
$
(
document
).
ready
(
function
()
{
var
editor
=
ace
.
edit
(
"
editor
"
);
editor
.
setTheme
(
"
ace/theme/crimson_editor
"
);
var
CurentMode
=
require
(
"
ace/mode/buildout
"
).
Mode
;
editor
.
getSession
().
setMode
(
new
CurentMode
());
editor
.
getSession
().
setTabSize
(
2
);
editor
.
getSession
().
setUseSoftTabs
(
true
);
editor
.
renderer
.
setHScrollBarAlwaysVisible
(
false
);
var
file
=
$
(
"
input#profile
"
).
val
();
var
edit
=
false
;
selectFile
(
file
);
$
(
"
#save
"
).
click
(
function
(){
if
(
!
edit
){
error
(
"
Error: Can not load your file, please make sure that you have selected a Software Release
"
);
return
false
;
}
send
=
false
;
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/saveFileContent
'
,
data
:
{
file
:
file
,
content
:
editor
.
getSession
().
getValue
()},
success
:
function
(
data
){
if
(
data
.
code
==
1
){
error
(
"
File Saved!
"
);
}
else
{
error
(
data
.
result
);
}
send
=
false
;
}
});
return
false
;
});
function
error
(
msg
){
$
(
"
#flash
"
).
fadeOut
(
'
normal
'
);
$
(
"
#flash
"
).
empty
();
$
(
"
#flash
"
).
fadeIn
(
'
normal
'
);
$
(
"
#flash
"
).
append
(
"
<ul class='flashes'><li>
"
+
msg
+
"
</li></ul>
"
);
}
function
selectFile
(
file
){
edit
=
false
;
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/getFileContent
'
,
data
:
"
file=
"
+
file
,
success
:
function
(
data
){
if
(
data
.
code
==
1
){
editor
.
getSession
().
setValue
(
data
.
result
);
edit
=
true
;
}
else
{
error
(
"
Error: Can not load your file, please make sure that you have selected a Software Release
"
);
}
}
});
return
;
}
});
\ No newline at end of file
slapos/runner/templates/layout.html
View file @
c33f0922
...
@@ -14,27 +14,6 @@
...
@@ -14,27 +14,6 @@
<link
href=
"{{ url_for('static', filename='css/styles.css', _external=False) }}"
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
/>
<link
href=
"{{ url_for('static', filename='css/styles.css', _external=False) }}"
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
/>
<script
src=
"{{ url_for('static', filename='jquery/jquery-1.6.2.min.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='jquery/jquery-1.6.2.min.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
{% if request.path == '/editSoftwareProfile' or request.path == '/editInstanceProfile' %}
<script
src=
"{{ url_for('static', filename='ace/ace-uncompressed.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/theme-crimson_editor.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/mode-buildout.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
var
editor
=
ace
.
edit
(
"
editor
"
);
editor
.
setTheme
(
"
ace/theme/crimson_editor
"
);
var
CurentMode
=
require
(
"
ace/mode/buildout
"
).
Mode
;
editor
.
getSession
().
setMode
(
new
CurentMode
());
editor
.
getSession
().
setTabSize
(
2
);
editor
.
getSession
().
setUseSoftTabs
(
true
);
editor
.
renderer
.
setHScrollBarAlwaysVisible
(
false
);
$
(
'
#save
'
).
click
(
function
(){
$
(
'
#editor_content
'
).
val
(
editor
.
getSession
().
getValue
());
});
});
</script>
{% endif %}
<script
type=
text/javascript
>
<script
type=
text/javascript
>
$SCRIPT_ROOT
=
{{
request
.
script_root
|
tojson
|
safe
}};
$SCRIPT_ROOT
=
{{
request
.
script_root
|
tojson
|
safe
}};
</script>
</script>
...
...
slapos/runner/templates/updateInstanceProfile.html
View file @
c33f0922
{% extends "layout.html" %}
{% extends "layout.html" %}
{% block title %}Update instance profile{% endblock %}
{% block title %}Update instance profile{% endblock %}
{% block head %}
{{ super() }}
<script
src=
"{{ url_for('static', filename='ace/ace-uncompressed.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/theme-crimson_editor.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/mode-buildout.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='scripts/editor.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
{% endblock %}
{% block body %}
{% block body %}
<form
action=
"{{ url_for('updateInstanceProfile') }}"
method=
post
class=
add-entry
>
<form
method=
post
class=
add-entry
>
<dl>
<dl>
<dd><h2>
Instance Profile:
</h2></dd>
<dd><h2>
Instance Profile:
</h2></dd>
<dd>
<!--<textarea name=content rows=20 cols=103 id="editor">{{ profile }}</textarea>-->
<dd>
<div
class=
"main_content"
>
<div
class=
"main_content"
>
<pre
id=
"editor"
>
<pre
id=
"editor"
></pre>
{{ profile }}
<input
type=
"hidden"
name=
"profile"
id=
"profile"
value=
"{{ profile|safe }}"
/>
</pre>
</div>
</div>
<input
type=
"hidden"
name=
content
id=
"editor_content"
/>
<input
type=
"hidden"
name=
content
id=
"editor_content"
/>
</dd>
</dd>
...
...
slapos/runner/templates/updateSoftwareProfile.html
View file @
c33f0922
{% extends "layout.html" %}
{% extends "layout.html" %}
{% block title %}Update software profile{% endblock %}
{% block title %}Update software profile{% endblock %}
{% block head %}
{{ super() }}
<script
src=
"{{ url_for('static', filename='ace/ace-uncompressed.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/theme-crimson_editor.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='ace/mode-buildout.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"{{ url_for('static', filename='scripts/editor.js') }}"
type=
"text/javascript"
charset=
"utf-8"
></script>
{% endblock %}
{% block body %}
{% block body %}
<form
action=
"{{ url_for('updateSoftwareProfile') }}"
method=
post
class=
add-entry
>
<form
method=
post
class=
add-entry
>
<dl>
<dl>
<dt><strong>
Note:
</strong>
Url of instance.cfg is
<tt>
{{ instance_url }}
</tt></dt>
<dt><strong>
Note:
</strong>
Url of instance.cfg is
<tt>
{{ instance_url }}
</tt></dt>
<dd><h2>
Software Profile:
</h2></dd>
<dd><h2>
Software Profile:
</h2></dd>
<dd>
<!--<textarea name=content rows=20 cols=103 id="editor">{{ profile }}</textarea>-->
<dd>
<div
class=
"main_content"
>
<div
class=
"main_content"
>
<pre
id=
"editor"
>
<pre
id=
"editor"
></pre>
{{ profile }}
</pre>
</div>
</div>
<input
type=
"hidden"
value=
"{{ profile }}"
name=
content
id=
"editor_content"
/>
<input
type=
"hidden"
name=
"profile"
id=
"profile"
value=
"{{ profile|safe }}"
/>
</dd>
</dd>
<dd><input
type=
submit
value=
Update
id=
"save"
class=
"button"
></dd>
<dd><input
type=
submit
value=
Update
id=
"save"
class=
"button"
></dd>
</dl>
</dl>
...
...
slapos/runner/views.py
View file @
c33f0922
...
@@ -4,7 +4,7 @@ from utils import *
...
@@ -4,7 +4,7 @@ from utils import *
import
os
import
os
import
shutil
import
shutil
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
createBranch
,
getDiff
,
\
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
createBranch
,
getDiff
,
\
gitPush
gitPush
,
gitPull
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
...
@@ -27,7 +27,7 @@ def configRepo():
...
@@ -27,7 +27,7 @@ def configRepo():
# software views
# software views
@
app
.
route
(
'/editSoftwareProfile'
)
@
app
.
route
(
'/editSoftwareProfile'
)
def
editSoftwareProfile
():
def
editSoftwareProfile
():
profile
=
getProfile
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'software_profile'
])
profile
=
getProfile
Path
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'software_profile'
])
if
profile
==
""
:
if
profile
==
""
:
flash
(
'Error: can not open profile, please select your project first'
)
flash
(
'Error: can not open profile, please select your project first'
)
return
render_template
(
'updateSoftwareProfile.html'
,
return
render_template
(
'updateSoftwareProfile.html'
,
...
@@ -75,17 +75,10 @@ def viewSoftwareLog():
...
@@ -75,17 +75,10 @@ def viewSoftwareLog():
return
render_template
(
'viewLog.html'
,
type
=
'Software'
,
return
render_template
(
'viewLog.html'
,
type
=
'Software'
,
result
=
result
,
running
=
isSoftwareRunning
(
app
.
config
))
result
=
result
,
running
=
isSoftwareRunning
(
app
.
config
))
@
app
.
route
(
'/updateSoftwareProfile'
,
methods
=
[
'POST'
])
def
updateSoftwareProfile
():
profile
=
getProfilePath
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'software_profile'
])
if
profile
!=
""
:
open
(
profile
,
'w'
).
write
(
request
.
form
[
'content'
])
return
redirect
(
url_for
(
'editSoftwareProfile'
))
# instance views
# instance views
@
app
.
route
(
'/editInstanceProfile'
)
@
app
.
route
(
'/editInstanceProfile'
)
def
editInstanceProfile
():
def
editInstanceProfile
():
profile
=
getProfile
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'instance_profile'
])
profile
=
getProfile
Path
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'instance_profile'
])
if
profile
==
""
:
if
profile
==
""
:
flash
(
'Error: can not open instance profile for this Software Release'
)
flash
(
'Error: can not open instance profile for this Software Release'
)
return
render_template
(
'updateInstanceProfile.html'
,
return
render_template
(
'updateInstanceProfile.html'
,
...
@@ -136,13 +129,6 @@ def viewInstanceLog():
...
@@ -136,13 +129,6 @@ def viewInstanceLog():
return
render_template
(
'viewLog.html'
,
type
=
'Instance'
,
return
render_template
(
'viewLog.html'
,
type
=
'Instance'
,
result
=
result
,
running
=
isInstanceRunning
(
app
.
config
))
result
=
result
,
running
=
isInstanceRunning
(
app
.
config
))
@
app
.
route
(
'/updateInstanceProfile'
,
methods
=
[
'POST'
])
def
updateInstanceProfile
():
profile
=
getProfilePath
(
app
.
config
[
'runner_workdir'
],
app
.
config
[
'instance_profile'
])
if
profile
!=
""
:
open
(
profile
,
'w'
).
write
(
request
.
form
[
'content'
])
return
redirect
(
url_for
(
'editInstanceProfile'
))
@
app
.
route
(
'/stopAllPartition'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/stopAllPartition'
,
methods
=
[
'GET'
])
def
stopAllPartition
():
def
stopAllPartition
():
svcStopAll
(
app
.
config
)
svcStopAll
(
app
.
config
)
...
@@ -287,4 +273,8 @@ def getProjectDiff(project):
...
@@ -287,4 +273,8 @@ def getProjectDiff(project):
@
app
.
route
(
"/pushProjectFiles"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/pushProjectFiles"
,
methods
=
[
'POST'
])
def
pushProjectFiles
():
def
pushProjectFiles
():
return
gitPush
(
request
.
form
[
'project'
],
request
.
form
[
'msg'
],
False
)
return
gitPush
(
request
.
form
[
'project'
],
request
.
form
[
'msg'
])
\ No newline at end of file
@
app
.
route
(
"/pullProjectFiles"
,
methods
=
[
'POST'
])
def
pullProjectFiles
():
return
gitPull
(
request
.
form
[
'project'
])
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment