Skip to content

Commit

Permalink
Adds validation for invalid hostname in multi data source
Browse files Browse the repository at this point in the history
Signed-off-by: Bandini Bhopi <[email protected]>
  • Loading branch information
bandinib-amzn committed Oct 19, 2023
1 parent e1db842 commit b212b34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/plugins/data_source/server/util/endpoint_validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@

import dns from 'dns-sync';
import IPCIDR from 'ip-cidr';
// eslint-disable-next-line @osd/eslint/no-restricted-paths
import { config } from '../../../../core/server/http';

export function isValidURL(endpoint: string, deniedIPs?: string[]) {
// Validate hostname e.g. https://abc.com<><><><img>
const httpSchema = config.schema;
const obj = {
host: endpoint,
};
try {
httpSchema.validate(obj);
} catch (err) {
return false;
}
// Check the format of URL, URL has be in the format as
// scheme://server/path/resource otherwise an TypeError
// would be thrown.
Expand Down

0 comments on commit b212b34

Please sign in to comment.