Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] modify rss http getter to a simple fetch (#8736) #9006

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions opencti-platform/opencti-graphql/src/manager/ingestionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
// endregion

// region Rss ingestion
type Getter = (uri: string) => Promise<object>;
type Getter = (uri: string) => Promise<string>;

interface RssElement {
pubDate: { _: string }
Expand All @@ -121,6 +121,7 @@
'content:encoded': { _: string }
category: { _: string } | { _: string }[]
pubDate: { _: string }
'dc:date': { _: string }
lastBuildDate: { _: string }
updated: { _: string }
}
Expand Down Expand Up @@ -154,19 +155,14 @@
link: isNotEmptyField(item.link) ? ((item.link as { _: string })._ ?? '').trim() : '',
content: turndownService.turndown(item['content:encoded']?._ ?? item.content?._ ?? ''),
labels: R.uniq(asArray(item.category).filter((c) => isNotEmptyField(c)).map((c) => (c as { _: string })._.trim())),
pubDate: utcDate(sanitizeForMomentParsing(item.pubDate?._ ?? pubDate?._ ?? FROM_START_STR)),
pubDate: utcDate(sanitizeForMomentParsing(item.pubDate?._ ?? item['dc:date']?._ ?? pubDate?._ ?? FROM_START_STR)),
};
};

const rssHttpGetter = (): Getter => {
const httpClientOptions: GetHttpClient = {
responseType: 'text',
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0' }
};
const httpClient = getHttpClient(httpClientOptions);
return async (uri: string) => {
const { data } = await httpClient.get(uri);
return data;
const fetchResponse = await fetch(uri);
return fetchResponse.text();

Check warning on line 165 in opencti-platform/opencti-graphql/src/manager/ingestionManager.ts

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/manager/ingestionManager.ts#L164-L165

Added lines #L164 - L165 were not covered by tests
};
};

Expand Down