Skip to content
This repository was archived by the owner on Mar 5, 2020. It is now read-only.

Commit 40bd0a7

Browse files
committed
Adding application security
1 parent 57cd7ed commit 40bd0a7

32 files changed

+164
-125
lines changed

src/main/java/pl/simplemethod/codebin/repository/UsersRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pl.simplemethod.codebin.repository;
22

33
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.data.jpa.repository.Query;
45
import org.springframework.stereotype.Repository;
56
import org.springframework.transaction.annotation.Transactional;
67

@@ -17,5 +18,6 @@ public interface UsersRepository extends JpaRepository<Users, Long> {
1718

1819
Users getFirstBySubscription(String subscription);
1920

21+
@Query(value = "SELECT u FROM Users u INNER JOIN u.containers c WHERE c.idDocker = :id")
2022
Users findByContainersidDocker(String id);
2123
}

src/main/resources/public/app.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ angular.module("CombineModule", ["mainApp", "dashboard"]);
4444

4545
app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope', '$http', function ($filter, $routeParams, $scope, $http) {
4646
$scope.supportedPlatforms = ["Java", "C", "C++", "Python", "HTML", "JavaScript", "CSS"];
47+
$scope.progressBar=0;
4748
$http({
4849
url: 'http://127.0.0.1/github/user/repos/' + $routeParams.id,
4950
method: 'GET'
@@ -59,11 +60,13 @@ app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope
5960
$scope.diskquota = null;
6061
if (!response.data.container_create) {
6162
if ($scope.supportedPlatforms.indexOf(response.data.language) !== -1) {
63+
$scope.progressBar=40;
6264
$http({
6365
url: 'http://127.0.0.1/github/local',
6466
method: 'GET'
6567
}).then(
6668
function (local) {
69+
$scope.progressBar=70;
6770
$scope.userId = local.data.user_id;
6871
$scope.subscriptionStatus = local.data.subscription_status;
6972
$scope.github_id = local.data.github_id;
@@ -82,6 +85,7 @@ app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope
8285
$scope.dockerImages = 4;
8386
}
8487
$scope.rammemory = $scope.diskquota = 1000000000;
88+
$scope.premiumtext="Free";
8589
} else {
8690
console.log("Pro user");
8791
if ($scope.supportedPlatforms.indexOf(response.data.language) === 0) {
@@ -94,6 +98,7 @@ app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope
9498
$scope.dockerImages = 2;
9599
}
96100
$scope.premium = 1;
101+
$scope.premiumtext="Premium";
97102
$scope.rammemory = $scope.diskquota = 2000000000;
98103
}
99104

@@ -108,7 +113,7 @@ app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope
108113
console.log("Port zewnętrzny:" + $scope.hostports);
109114
console.log("Nazwa dokeru:" + $scope.id);
110115
console.log("Ilość pamięci ram: " + $scope.rammemory + " i dysku: " + $scope.diskquota);
111-
116+
$scope.progressBar=90;
112117
$http({
113118
url: 'http://127.0.0.1/srv/container/create3',
114119
method: 'POST',
@@ -125,30 +130,37 @@ app.controller('ContainersCreateController', ['$filter', '$routeParams', '$scope
125130
}).then(
126131
function (create) {
127132
console.log(create.data);
133+
$scope.progressBar=100;
128134

129135
},
130136
function (create) {
137+
$scope.errors= "Problem with creating a container";
138+
$scope.erorType=0;
131139
console.error(create.data);
132140
}
133141
);
134142

135143
},
136144
function (response) {
137-
console.error("Problem with loading user data");
138-
window.location = "/";
145+
$scope.errors= "Problem with loading user data";
146+
$scope.erorType=1;
139147
}
140148
);
141149
} else {
142-
console.error("No support for the specified repository");
143-
window.location = "/";
150+
$scope.errors= "No support for the specified repository";
151+
$scope.erorType=2;
152+
144153
}
145154
} else {
155+
$scope.errors= "The repository does exist";
156+
$scope.erorType=3;
146157
console.error("The repository does exist");
147-
window.location = "/";
148158
}
149159

150160
},
151161
function (response) {
162+
$scope.errors= "Fatal Error";
163+
$scope.erorType=4;
152164
window.location = "/";
153165
}
154166
);
@@ -182,6 +194,7 @@ app.controller('ContainersController', ['$filter', '$routeParams', '$scope', '$h
182194
function (response) {
183195
},
184196
function (response) {
197+
$scope.errors= "Problem with restarting a container";
185198
}
186199
);
187200
};
@@ -191,8 +204,10 @@ app.controller('ContainersController', ['$filter', '$routeParams', '$scope', '$h
191204
method: 'DELETE'
192205
}).then(
193206
function (response) {
207+
$window.location.href="/";
194208
},
195209
function (response) {
210+
$scope.errors= "Problem with deleteing a container";
196211
}
197212
);
198213
};
@@ -204,6 +219,7 @@ app.controller('ContainersController', ['$filter', '$routeParams', '$scope', '$h
204219
$scope.logMachine = logGet.data.logs;
205220
},
206221
function (logGet) {
222+
$scope.errors= "Problem with downloading logs from containers";
207223
}
208224
);
209225
$http({
@@ -214,11 +230,12 @@ app.controller('ContainersController', ['$filter', '$routeParams', '$scope', '$h
214230
$scope.tops = response.data.Processes;
215231
},
216232
function (response) {
233+
$scope.errors= "Problem with getting processes from a container";
217234
}
218235
);
219236
},
220237
function (response) {
221-
window.location = "/";
238+
$scope.errors= "Fatal error";
222239
}
223240
);
224241
}]);
@@ -247,15 +264,18 @@ app.controller('HomeController', function ($scope, $http, $cookies) {
247264

248265
app.controller('ProjectsController', function ($scope, $http) {
249266
$scope.supportedPlatforms = ["Java", "HTML", "C", "C++", "JavaScript", "CSS"];
267+
250268
$http({
251269
url: 'http://127.0.0.1/github/user/repos/public',
252270
method: 'GET'
253271
}).then(
254272
function (response) {
255273
$scope.jsondata = response.data;
256274
$scope.repoid = response.data.id;
275+
$scope.progressBar=100;
257276
},
258277
function (response) {
278+
$scope.errors="Fatal error";
259279
}
260280
);
261281
});

src/main/resources/public/dashboard/container.html

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
<h3 class="page-title">{{containersId}}</h3>
55
</div>
66
</div>
7+
8+
9+
<div ng-if="errors" class="row">
10+
<div class="col">
11+
<div class="card card-small mb-4">
12+
<div class="card-header border-bottom">
13+
<h6 class="m-0">Errors</h6>
14+
<div class="card-body p-0 pb-3 text-center">
15+
<h5 style="text-align:center; color: #ff2600"><b>{{errors}}</b></h5>
16+
</div>
17+
</div>
18+
</div>
19+
</div>
20+
</div>
21+
722
<div class="row">
823
<div class="col">
924
<div class="card card-small mb-4">
@@ -53,16 +68,28 @@ <h6 class="m-0">General view</h6>
5368
<a class="ml-auto" href="http://127.0.0.1/share/{{shareStatus}}">Share link</a></span>
5469
<span ng-if="shareStatus === null" class="d-flex mb-2"><i
5570
class="material-icons mr-1">visibility</i><strong
56-
class="mr-1">Visibility:</strong> <strong class="text-danger"><a href="" data-toggle="modal" data-target="#local">Local access</a> </strong></span>
57-
<span class="d-flex mb-2"><i class="material-icons mr-1">calendar_today</i><strong class="mr-1">Creation time:</strong> <mydate>{{creationTime * 1000 | date:'dd-MM-yyyy HH:mm:ss'}}</mydate> </span>
71+
class="mr-1">Visibility:</strong> <strong class="text-danger"><a href=""
72+
data-toggle="modal"
73+
data-target="#local">Local access</a> </strong></span>
74+
<span class="d-flex mb-2"><i class="material-icons mr-1">calendar_today</i><strong
75+
class="mr-1">Creation time:</strong> <mydate>{{creationTime * 1000 | date:'dd-MM-yyyy HH:mm:ss'}}</mydate> </span>
5876

5977
<span class="d-flex mb-2">
60-
<button type="button" class="mb-2 btn btn-danger mr-2" ng-click="dockerRemove()">Remove container</button>
78+
<button type="button" class="mb-2 btn btn-danger mr-2" data-toggle="modal" data-target="#remove">Remove container</button>
6179
<button type="button" class=" ml-auto mb-2 btn btn-warning mr-2" ng-click="dockerRestart()">Restart container</button>
6280
</span>
6381
</ul>
6482
</div>
6583
</div>
84+
85+
<div ng-if="shareStatus === null" class="card card-small mb-3">
86+
<div class="card-header border-bottom">
87+
<h6 class="m-0">Advertising</h6>
88+
</div>
89+
<div class="card-body p-0">
90+
<div style="text-align: center"><img src="https://i.imgur.com/8jVsNBp.png"> </div>
91+
</div>
92+
</div>
6693
</div>
6794
</div>
6895
<div class="row">
@@ -88,7 +115,8 @@ <h6 class="m-0">Logs from the machine</h6>
88115
<div class="modal-content">
89116
<div class="modal-header">
90117
<h5 style="float:right;" class="modal-title">Local access</h5>
91-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
118+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
119+
aria-hidden="true">&times;</span>
92120
</button>
93121
</div>
94122
<div class="modal-body">
@@ -102,4 +130,23 @@ <h5 style="float:right;" class="modal-title">Local access</h5>
102130
</div>
103131
</div>
104132
</div>
133+
</div>
134+
135+
<div class="modal" tabindex="-1" role="dialog" id="remove">
136+
<div class="modal-dialog modal-sm" role="document">
137+
<div class="modal-content">
138+
<div class="modal-header">
139+
<h5 class="modal-title">Warning!</h5>
140+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
141+
</button>
142+
</div>
143+
<div class="modal-body">
144+
<div style="text-align: center"> <h5>Are you sure about delete the container?</h5>
145+
<button type="button" class="mb-2 btn btn-danger mr-2" ng-click="dockerRemove()">Remove container</button></div>
146+
</div>
147+
<div class="modal-footer">
148+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
149+
</div>
150+
</div>
151+
</div>
105152
</div>

src/main/resources/public/dashboard/containercreate.html

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,54 @@
44
<h3 class="page-title">Creation of a new container</h3>
55
</div>
66
</div>
7-
<div class="row">
8-
<div class="col">
9-
<div class="card card-small mb-4">
10-
<div class="card-header border-bottom">
11-
<h6 class="m-0">Basic information</h6>
12-
<span class="d-flex mb-2"><i class="material-icons mr-1">flag</i><strong class="mr-1">Status:</strong> Draft</span>
7+
8+
<div class="col-lg-12">
9+
<div class="card card-small card-post mb-4">
10+
<div class="card-body">
11+
<h5 class="card-title">{{name}}</h5>
12+
<p class="card-text text-muted">{{description}}</p>
13+
</div>
14+
<div class="card-footer border-top d-flex">
15+
<div class="card-post__author d-flex">
16+
<div class="d-flex flex-column justify-content-center">
17+
<span class="card-post__author-name">{{language}}</span>
18+
<small class="text-muted">{{created_at}}</small>
19+
</div>
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
<div class="col-lg-12">
25+
<div class="card card-small card-post mb-4">
26+
<div class="card-body">
27+
<h3>Basic information</h3>
28+
<div class="row">
29+
<hr>
30+
<div class="col">
31+
<span class="d-flex mb-2"><strong class="mr-1">User plan:</strong> {{premiumtext}}</span>
32+
<span class="d-flex mb-2"><strong
33+
class="mr-1">Exposed port:</strong> {{exposedports}}</span>
34+
<span class="d-flex mb-2"><strong
35+
class="mr-1">Host port:</strong> {{hostports}}</span>
36+
<span class="d-flex mb-2"><strong
37+
class="mr-1">Ram memory:</strong> {{rammemory/1000000000}} GB</span>
38+
<span class="d-flex mb-2"><strong
39+
class="mr-1">Disc space:</strong> {{diskquota/1000000000}} GB</span>
40+
41+
</div>
42+
</div>
43+
<hr>
44+
<h5><b>Installation process:</b></h5>
45+
46+
<div ng-if="errors">
47+
<h5 style="text-align:center; color: #ff2600"><b>{{errors}}</b></h5>
48+
</div>
49+
<span id="percentage">({{progressBar}}%)</span>
50+
<div class="progress progress-sm mb-3">
51+
<div id="" class="progress-bar" role="progressbar" ng-style="{width : ( progressBar + '%' ) }" aria-valuenow="{{progressBar}}" aria-valuemin="0" aria-valuemax="100"></div>
52+
</div>
53+
<div style="text-align:center;" ng-if="progressBar==100">
54+
<button type="button" onclick="location.href='/dashboard.html#!/containers/{{id}}'" class="mb-2 btn btn-primary mr-2">Go to the container</button>
1355
</div>
1456
</div>
1557
</div>

src/main/resources/public/dashboard/projects.html

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ <h3 class="page-title">Your GitHub projects</h3>
55
</div>
66
</div>
77

8+
<div ng-if="errors" class="row">
9+
<div class="col">
10+
<div class="card card-small mb-4">
11+
<div class="card-header border-bottom">
12+
<h6 class="m-0">Errors</h6>
13+
<div class="card-body p-0 pb-3 text-center">
14+
<h5 style="text-align:center; color: #ff2600"><b>{{errors}}</b></h5>
15+
</div>
16+
</div>
17+
</div>
18+
</div>
19+
</div>
20+
21+
<div ng-if="progressBar!==100 && !errors" class="row">
22+
<div class="col">
23+
<div class="card card-small mb-4">
24+
<div class="card-header border-bottom">
25+
<div style=" width: 0%;margin: 0 auto;">
26+
<div class="loading-overlay" style="text-align: center">
27+
<div class="spinner"></div>
28+
</div>
29+
</div>
30+
<div class="card-body p-0 pb-3 text-center">
31+
<h5 style="text-align:center;"><b>We're exploring your repository. Please stand by</b></h5>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
837
<div class="row">
938

1039
<div ng-repeat="x in jsondata" class="col-lg-12">
@@ -21,14 +50,17 @@ <h5 class="card-title">{{x.name}}</h5>
2150
</div>
2251
</div>
2352
<div class="my-auto ml-auto">
24-
25-
<a ng-if="x.container_create !== null" class="btn btn-normal btn-primary " href="/dashboard.html#!/containers/{{x.container_create}}">
53+
<a ng-if="x.container_create !== null" class="btn btn-normal btn-primary "
54+
href="/dashboard.html#!/containers/{{x.container_create}}">
2655
<i class="fas fa-cogs mr-1"></i> Open </a>
27-
<a ng-if="supportedPlatforms.indexOf(x.language) !== -1 && x.container_create === null" class="btn btn-normal btn-primary " href="/dashboard.html#!/create/{{x.id}}">
56+
<a ng-if="supportedPlatforms.indexOf(x.language) !== -1 && x.container_create === null"
57+
class="btn btn-normal btn-primary " href="/dashboard.html#!/create/{{x.id}}">
2858
<i class="fas fa-cogs mr-1"></i> Run </a>
29-
<a ng-if="supportedPlatforms.indexOf(x.language) === -1" class="btn btn-normal btn-primary disabled" href="#">
59+
<a ng-if="supportedPlatforms.indexOf(x.language) === -1" class="btn btn-normal btn-primary disabled"
60+
href="#">
3061
<i class="fas fa-cogs mr-1"></i> Unsupported</a>
3162
</div>
63+
3264
</div>
3365
</div>
3466
</div>
69.5 KB
Loading
-13.3 KB
Binary file not shown.
-2.84 KB
Binary file not shown.
-5.3 KB
Binary file not shown.
-4.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)