@@ -14,8 +14,10 @@ import (
14
14
15
15
"github.com/1Panel-dev/1Panel/backend/app/dto"
16
16
"github.com/1Panel-dev/1Panel/backend/app/model"
17
+ "github.com/1Panel-dev/1Panel/backend/buserr"
17
18
"github.com/1Panel-dev/1Panel/backend/constant"
18
19
"github.com/1Panel-dev/1Panel/backend/global"
20
+ "github.com/1Panel-dev/1Panel/backend/utils/cmd"
19
21
"github.com/1Panel-dev/1Panel/backend/utils/compose"
20
22
"github.com/1Panel-dev/1Panel/backend/utils/docker"
21
23
"github.com/docker/docker/api/types"
@@ -127,6 +129,9 @@ func (u *ContainerService) PageCompose(req dto.SearchWithPage) (int64, interface
127
129
}
128
130
129
131
func (u * ContainerService ) TestCompose (req dto.ComposeCreate ) (bool , error ) {
132
+ if cmd .CheckIllegal (req .Path ) {
133
+ return false , buserr .New (constant .ErrCmdIllegal )
134
+ }
130
135
composeItem , _ := composeRepo .GetRecord (commonRepo .WithByName (req .Name ))
131
136
if composeItem .ID != 0 {
132
137
return false , constant .ErrRecordExist
@@ -143,6 +148,9 @@ func (u *ContainerService) TestCompose(req dto.ComposeCreate) (bool, error) {
143
148
}
144
149
145
150
func (u * ContainerService ) CreateCompose (req dto.ComposeCreate ) (string , error ) {
151
+ if cmd .CheckIllegal (req .Name , req .Path ) {
152
+ return "" , buserr .New (constant .ErrCmdIllegal )
153
+ }
146
154
if err := u .loadPath (& req ); err != nil {
147
155
return "" , err
148
156
}
@@ -177,6 +185,9 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error)
177
185
}
178
186
179
187
func (u * ContainerService ) ComposeOperation (req dto.ComposeOperation ) error {
188
+ if cmd .CheckIllegal (req .Path , req .Operation ) {
189
+ return buserr .New (constant .ErrCmdIllegal )
190
+ }
180
191
if _ , err := os .Stat (req .Path ); err != nil {
181
192
return fmt .Errorf ("load file with path %s failed, %v" , req .Path , err )
182
193
}
@@ -195,6 +206,9 @@ func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
195
206
}
196
207
197
208
func (u * ContainerService ) ComposeUpdate (req dto.ComposeUpdate ) error {
209
+ if cmd .CheckIllegal (req .Name , req .Path ) {
210
+ return buserr .New (constant .ErrCmdIllegal )
211
+ }
198
212
if _ , err := os .Stat (req .Path ); err != nil {
199
213
return fmt .Errorf ("load file with path %s failed, %v" , req .Path , err )
200
214
}
0 commit comments