File tree Expand file tree Collapse file tree 8 files changed +51
-4
lines changed Expand file tree Collapse file tree 8 files changed +51
-4
lines changed Original file line number Diff line number Diff line change
1
+ ### v0.3.1
2
+ - only support http/https to convert,disabled to reach file system.
1
3
### v0.3.0
2
4
- support waiting time for html convert to pdf
3
5
- support waiting time for html convert to image
Original file line number Diff line number Diff line change
1
+ # check list
2
+ - common/const.go Version
3
+ - CHANGELOG.md
4
+ - Makefile
5
+ - merge branch
6
+ - docker build and push to docker hub
Original file line number Diff line number Diff line change 1
1
.DEFAULT : help
2
2
3
3
IMAGE_NAME ?= lampnick/doctron
4
- CENTOS_IMAGE_TAG ?= v0.3.0 -centos
5
- ALPINE_IMAGE_TAG ?= v0.3.0 -alpine
4
+ CENTOS_IMAGE_TAG ?= v0.3.1 -centos
5
+ ALPINE_IMAGE_TAG ?= v0.3.1 -alpine
6
6
7
7
help : Makefile
8
8
@echo " Doctron is a document convert tools for html pdf image etc.\r\n"
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ Use this section to tell people about which versions of your project are
6
6
currently being supported with security updates.
7
7
8
8
| Version | Supported |
9
- | ------- | ------------------ |
9
+ | 0.3.1 | ensure can't visit the file system |
10
10
11
11
12
12
## Reporting a Vulnerability
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ func NewDoctron() *iris.Application {
19
19
}
20
20
})
21
21
app .PartyFunc ("/convert" , func (convert router.Party ) {
22
+ convert .Use (middleware .CheckParams )
22
23
convert .Use (middleware .AuthMiddleware )
23
24
convert .Use (middleware .CheckRateLimiting )
24
25
convert .Get ("/html2pdf" , controller .Html2PdfHandler )
Original file line number Diff line number Diff line change 1
1
package common
2
2
3
3
//Version Version
4
- const Version = "0.3.0 "
4
+ const Version = "0.3.1 "
Original file line number Diff line number Diff line change 7
7
InvalidParams = 10000001
8
8
InvalidUrl = 10000002
9
9
ApiRateLimitExceeded = 10000003
10
+ InvalidUrlScheme = 10000004
10
11
ConvertPdfFailed = 20000000
11
12
ConvertPdfWriteBytesFailed = 20000001
12
13
ConvertPdfUploadFailed = 20000002
@@ -28,6 +29,7 @@ var ErrMsg = map[int]string{
28
29
InvalidParams : "invalid params" ,
29
30
InvalidUrl : "invalid url" ,
30
31
ApiRateLimitExceeded : "api rate limit exceeded" ,
32
+ InvalidUrlScheme : "only support http/https" ,
31
33
ConvertPdfFailed : "failed convert html to pdf" ,
32
34
ConvertPdfWriteBytesFailed : "failed convert html to pdf. write bytes failed" ,
33
35
ConvertPdfUploadFailed : "failed convert html to pdf. upload failed" ,
Original file line number Diff line number Diff line change
1
+ package middleware
2
+
3
+ import (
4
+ "net/url"
5
+
6
+ "github.com/kataras/iris/v12"
7
+ "github.com/lampnick/doctron/common"
8
+ )
9
+
10
+ func CheckParams (ctx iris.Context ) {
11
+ webUrl := ctx .URLParam ("url" )
12
+ if webUrl == "" {
13
+ outputDTO := common .NewDefaultOutputDTO (nil )
14
+ outputDTO .Code = common .InvalidUrl
15
+ _ , _ = common .NewJsonOutput (ctx , outputDTO )
16
+ return
17
+ }
18
+
19
+ u , err := url .Parse (webUrl )
20
+ if err != nil {
21
+ outputDTO := common .NewDefaultOutputDTO (nil )
22
+ outputDTO .Code = common .InvalidUrl
23
+ outputDTO .Message = err .Error ()
24
+ _ , _ = common .NewJsonOutput (ctx , outputDTO )
25
+ return
26
+ }
27
+
28
+ if u .Scheme != "http" && u .Scheme != "https" {
29
+ outputDTO := common .NewDefaultOutputDTO (nil )
30
+ outputDTO .Code = common .InvalidUrlScheme
31
+ _ , _ = common .NewJsonOutput (ctx , outputDTO )
32
+ return
33
+ }
34
+
35
+ ctx .Next ()
36
+ }
You can’t perform that action at this time.
0 commit comments