-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
515 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exports['test/xss.test.ts should set X-XSS-Protection header value 0 when config is number 0 1'] = { | ||
"enable": true, | ||
"value": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
import { EggCore } from '@eggjs/core'; | ||
import { safeCurlForApplication } from '../../lib/extend/safe_curl.js'; | ||
import { | ||
safeCurlForApplication, | ||
type HttpClientRequestURL, | ||
type HttpClientOptions, | ||
type HttpClientResponse, | ||
} from '../../lib/extend/safe_curl.js'; | ||
|
||
export default class SecurityAgent extends EggCore { | ||
safeCurl = safeCurlForApplication; | ||
async safeCurl<T = any>( | ||
url: HttpClientRequestURL, options?: HttpClientOptions): Promise<HttpClientResponse<T>> { | ||
return await safeCurlForApplication<T>(this, url, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app) { | ||
app.get('/', function *(){ | ||
app.get('/', function(){ | ||
this.body = '123'; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app) { | ||
app.get('/', function *(){ | ||
app.get('/', function(){ | ||
this.body = '123'; | ||
}); | ||
|
||
app.get('/disable', function *(){ | ||
app.get('/disable', function(){ | ||
this.securityOptions.noopen = { enable: false }; | ||
this.body = '123'; | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/fixtures/apps/referrer-config-compatibility/app/router.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = function(app) { | ||
app.get('/', function() { | ||
this.body = '123'; | ||
}); | ||
app.get('/referrer', function() { | ||
const policy = this.query.policy; | ||
this.body = '123'; | ||
this.securityOptions.refererPolicy = { | ||
enable: true, | ||
value: policy | ||
} | ||
}); | ||
}; |
11 changes: 11 additions & 0 deletions
11
test/fixtures/apps/referrer-config-compatibility/config/config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
exports.keys = 'test key'; | ||
|
||
exports.security = { | ||
defaultMiddleware: 'referrerPolicy', | ||
referrerPolicy: { | ||
value: 'origin', | ||
enable: true | ||
}, | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/referrer-config-compatibility/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "referrer-config" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app) { | ||
app.get('/', function *(){ | ||
app.get('/', function() { | ||
this.body = '123'; | ||
}); | ||
app.get('/referrer', function *(){ | ||
app.get('/referrer', function() { | ||
const policy = this.query.policy; | ||
this.body = '123'; | ||
this.securityOptions.refererPolicy = { | ||
this.securityOptions.referrerPolicy = { | ||
enable: true, | ||
value: policy | ||
} | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app) { | ||
app.get('/', function *(){ | ||
app.get('/', function(){ | ||
this.body = '123'; | ||
}); | ||
}; | ||
}; |
Oops, something went wrong.