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

Merge recent develop to branch #7066

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const getTimestamp = async () => {
throw new Error('Invalid file path detected');
}

const MAX_FILE_SIZE = 10 * 1024; // 10 KB max file size
const stats = await promisify(fs.stat)(filePath);
if (stats.size > MAX_FILE_SIZE) {
throw new Error('File is too large and may cause DoS issues');
}
// const MAX_FILE_SIZE = 10 * 1024; // 10 KB max file size
// const stats = await promisify(fs.stat)(filePath);
// if (stats.size > MAX_FILE_SIZE) {
// throw new Error('File is too large and may cause DoS issues');
// }

const fileContent = await promisify(fs.readFile)(filePath, 'utf-8');

Expand Down
19 changes: 11 additions & 8 deletions src/server/services/communities.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const getValidIds = async (METADATA_PATH) => {
// Check if the file exists
await promisify(fs.access)(uri);

// Get file stats
const stats = await promisify(fs.stat)(uri);
const MAX_FILE_SIZE = 1 * 1024 * 1024; // 1 MB
if (stats.size > MAX_FILE_SIZE) {
console.warn(`Metadata file too large for ID: ${id}`);
return null; // Exclude invalid ID
}
// // Get file stats
// const stats = await promisify(fs.stat)(uri);
// const MAX_FILE_SIZE = 1 * 1024 * 1024; // 1 MB
// if (stats.size > MAX_FILE_SIZE) {
// console.warn(`Metadata file too large for ID: ${id}`);
// return null; // Exclude invalid ID
// }

// Parse and validate JSON
const meta = JSON.parse(await promisify(fs.readFile)(uri, 'utf8'));
Expand All @@ -61,21 +61,24 @@ const getValidIds = async (METADATA_PATH) => {
if (typeof subdomain === 'string') {
SUBDOMAIN_COMMUNITY[subdomain] = id;
} else {
// eslint-disable-next-line no-console
console.warn(`Invalid subdomain entry for ID: ${id}`);
}
});
}

return id;
} catch (e) {
// eslint-disable-next-line no-console
console.error(`Error processing metadata for ID: ${id}`, e.message);
return null;
return [];
}
});

const results = await Promise.all(validationPromises);
VALID_IDS = results.filter(id => id !== null);
} catch (err) {
// eslint-disable-next-line no-console
console.error(`Error reading metadata directory: ${METADATA_PATH}`, err.message);
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class ArticleCard extends React.Component {
themeName,
} = this.props;

if (!theme) {
// eslint-disable-next-line no-console
console.log('ArticleCard: missing theme property');
}

// determine if article cards will redirect to external link or article details page
const articlePageUrl = article.externalArticle && article.contentUrl
? article.contentUrl
Expand Down