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

Issue 975 #982

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Issue 975 #982

wants to merge 2 commits into from

Conversation

zchisholm
Copy link

Title: Refactor Campaigns Route to Enforce Least Privilege and Limit Data Exposure

Issue: #957

Description:

This pull request refactors the GET /campaigns route to apply the Principle of Least Privilege and limit data exposure. The changes ensure that only the necessary fields (name, startDate, and endDate) are returned to API consumers, minimizing the risk of exposing sensitive information.

Changes Made:

  • Refactored the GET /campaigns route to return only specific fields from the Campaign collection.
    • The fields returned are name, startDate, and endDate.
    • This limits data exposure and adheres to the Principle of Least Privilege by reducing the risk of exposing unnecessary data.

Before Refactor:

The GET /campaigns route returned all fields from the Campaign collection, exposing more data than necessary:

const campaigns = await Campaign.find({});
res.status(200).json(campaigns);

After Refactor:

Now, the GET /campaigns route only returns the name, startDate, and endDate fields:

const campaigns = await Campaign.find({}, 'name startDate endDate');
res.status(200).json(campaigns);

Dunridge and others added 2 commits October 19, 2024 01:13
Made changes to refactor a portion of the code in campaigns.js to apply the priciple of least privilege in the API and minimized data exposure.
Copy link

emote

Copy link

Hello there, thanks for opening your first Pull Request. Someone will review it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants