File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ var ui = `
99 <head>
1010 <meta charset="UTF-8">
1111 <title>Swagger UI</title>
12- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5 /swagger-ui.css" >
12+ <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.29.1 /swagger-ui.css" integrity="sha512-eZpfl9qlKnbDvlJ2brfdx3nhlP1FMsA23w65motxKdYsUcfMcdO2bcLPr7mXhvyzmDZwuzYCJKrl/sEo1ditVQ==" crossorigin="anonymous" referrerpolicy="no-referrer " >
1313 <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
1414 <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
1515 <style>
@@ -36,8 +36,8 @@ var ui = `
3636 <body>
3737 <div id="swagger-ui"></div>
3838
39- <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5 /swagger-ui-bundle.js"> </script>
40- <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5 /swagger-ui-standalone-preset.js"> </script>
39+ <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.29.1 /swagger-ui-bundle.js" integrity="sha512-iDdi6WwSTimAFh1NhPyFZpHJWr16m/PupHztElqQL+gQoQDavUATsP9hcvgs9Yci+EUA//WvZYZsCTDhRDKc3g==" crossorigin="anonymous" referrerpolicy="no-referrer "> </script>
40+ <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.29.1 /swagger-ui-standalone-preset.js" integrity="sha512-oGq+mP+3XUyYDm9vsprsd6YdhOokdkcLNUZnmEE6HJzG0F9fIaB8kgGZsjdfTWN8w/1f2kN4a/0xkla0hsetcQ==" crossorigin="anonymous" referrerpolicy="no-referrer "> </script>
4141 <script>
4242 function getBaseURL() {
4343 var path = window.location.pathname
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package docs
22
33import (
44 "net/http/httptest"
5+ "regexp"
56 "testing"
67
78 "github.com/gin-gonic/gin"
@@ -22,3 +23,12 @@ func TestUI(t *testing.T) {
2223 content := recorder .Body .String ()
2324 assert .NotEmpty (t , content )
2425}
26+
27+ func TestUIExternalResourcesHaveIntegrity (t * testing.T ) {
28+ tags := regexp .MustCompile (`<(?:script|link)[^>]*https://[^>]*>` ).FindAllString (ui , - 1 )
29+ assert .Len (t , tags , 3 )
30+ for _ , tag := range tags {
31+ assert .Regexp (t , `integrity="sha512-[A-Za-z0-9+/=]+"` , tag )
32+ assert .Contains (t , tag , `crossorigin="anonymous"` )
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments