Skip to content

Commit

Permalink
fix(core): Ensure .service does not access Object properties (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Jul 14, 2023
1 parent 818572d commit c0b670a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/feathers/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Feathers<Services, Settings>
location: L
): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]> {
const path = (stripSlashes(location) || '/') as L
const current = this.services[path]
const current = this.services.hasOwnProperty(path) ? this.services[path] : undefined

if (typeof current === 'undefined') {
this.use(path, this.defaultService(path) as any)
Expand Down
14 changes: 14 additions & 0 deletions packages/feathers/test/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ describe('Feathers application', () => {

assert.ok((wrappedService.create as any)[TEST])
})

it('.service does does not access object properties', async () => {
const app = feathers()

assert.throws(() => app.service('something'), {
message: "Can not find service 'something'"
})
assert.throws(() => app.service('__proto__'), {
message: "Can not find service '__proto__'"
})
assert.throws(() => app.service('toString'), {
message: "Can not find service 'toString'"
})
})
})

describe('Express app options compatibility', function () {
Expand Down

0 comments on commit c0b670a

Please sign in to comment.