Skip to content

Commit

Permalink
rka-19: fix the security warning, added allowed hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
konstrybakov committed Jun 9, 2024
1 parent 187c296 commit c57972a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/db/queries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO: split this file

import { and, eq, notInArray, sql } from 'drizzle-orm'
import { logger } from '../logger'
import { db } from './db'
import { type InsertCompany, type InsertJob, companies, jobs } from './schema'

Expand Down Expand Up @@ -85,8 +84,6 @@ export const queryMarkJobsAsClosed = async (
companyId: number,
openJobs: InsertJob[],
) => {
logger.debug(openJobs.map(({ url }) => url))

const result = await db
.update(jobs)
.set({ status: 'closed' })
Expand Down
2 changes: 2 additions & 0 deletions lib/hiring-platforms/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { HiringPlatformName, SelectCompany } from '../db/schema'
export abstract class HiringPlatform {
constructor(protected url: URL) {}

abstract allowedHosts: string[]

abstract checkURL(): Promise<HiringPlatformName>
abstract fetchJobs(companyId: SelectCompany['id']): Promise<void>
}
4 changes: 3 additions & 1 deletion lib/hiring-platforms/greenhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ type GreenhouseJob = {
}

export class Greenhouse extends HiringPlatform {
allowedHosts = ['boards.eu.greenhouse.io', 'boards.greenhouse.io']

async checkURL(): Promise<HiringPlatformName> {
if (!this.url.hostname.endsWith('greenhouse.io')) {
if (!this.allowedHosts.includes(this.url.host)) {
throw new Error('[Greenhouse] URL mismatch')
}

Expand Down

0 comments on commit c57972a

Please sign in to comment.