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

fix(orc8r): Sanitizing user input on N/W creation #15370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jahid-wavelabs
Copy link
Contributor

Fixes security issues #159

Summary

The current implementation includes sanitization of network inputs through the use of predefined allowedNetworkTypes. To enhance clarity and efficiency, this modification involves removing the reference to data.networkType from the else section.

Test Plan

This change was validated manually by deliberately sending a web-inject script. The testing process confirmed that the input is effectively filtered, and the system appropriately responds with an error.

@jahid-wavelabs jahid-wavelabs requested a review from a team as a code owner January 29, 2024 09:32
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines. label Jan 29, 2024
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added the component: nms NMS-related issue label Jan 29, 2024
Copy link
Contributor

github-actions bot commented Jan 29, 2024

✔️ The Semantic PR check ended with status success. See instructions on formatting your commit and pull request titles.

Comment on lines 187 to 190
res
.status(400)
.send(`Unsupported network type ${data.networkType}`)
.send(`Unsupported network type}`)
.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace ⏎············.status(400)⏎············.send(Unsupported·network·type})⏎············ with .status(400).send(Unsupported·network·type})

Suggested change
res
.status(400)
.send(`Unsupported network type ${data.networkType}`)
.send(`Unsupported network type}`)
.end();
res.status(400).send(`Unsupported network type}`).end();

@moinuddin1980 moinuddin1980 force-pushed the topic/sec-issues/whitelisting-net-type branch from a1b194e to 8bb8f56 Compare January 29, 2024 09:38
Comment on lines 187 to 190
res
.status(400)
.send(`Unsupported network type ${data.networkType}`)
.send(`Unsupported network type`)
.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace ⏎············.status(400)⏎············.send(Unsupported·network·type)⏎············ with .status(400).send(Unsupported·network·type)

Suggested change
res
.status(400)
.send(`Unsupported network type ${data.networkType}`)
.send(`Unsupported network type`)
.end();
res.status(400).send(`Unsupported network type`).end();

@moinuddin1980 moinuddin1980 force-pushed the topic/sec-issues/whitelisting-net-type branch from 8bb8f56 to 05cd710 Compare January 30, 2024 06:25
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines. and removed size/XS Denotes a PR that changes 0-9 lines. labels Jan 30, 2024
const allowedNetworkTypes = ['LTE', 'FEG_LTE', 'CWF', 'FEG'];

if (!allowedNetworkTypes.includes(data.networkType?.toUpperCase())) {
const allowedNetworkTypes: typeof data["networkType"][] = [LTE, FEG_LTE, CWF, FEG];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <@typescript-eslint/array-type> reported by reviewdog 🐶
Array type using 'T[]' is forbidden. Use 'Array' instead.

Suggested change
const allowedNetworkTypes: typeof data["networkType"][] = [LTE, FEG_LTE, CWF, FEG];
const allowedNetworkTypes: Array<typeof data["networkType"]> = [LTE, FEG_LTE, CWF, FEG];

const allowedNetworkTypes = ['LTE', 'FEG_LTE', 'CWF', 'FEG'];

if (!allowedNetworkTypes.includes(data.networkType?.toUpperCase())) {
const allowedNetworkTypes: typeof data["networkType"][] = [LTE, FEG_LTE, CWF, FEG];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace "networkType"][]·=·[LTE,·FEG_LTE,·CWF,·FEG with 'networkType'][]·=·[⏎········LTE,⏎········FEG_LTE,⏎········CWF,⏎········FEG,⏎······

Suggested change
const allowedNetworkTypes: typeof data["networkType"][] = [LTE, FEG_LTE, CWF, FEG];
const allowedNetworkTypes: typeof data['networkType'][] = [
LTE,
FEG_LTE,
CWF,
FEG,
];


if (!allowedNetworkTypes.includes(data.networkType?.toUpperCase())) {
const allowedNetworkTypes: typeof data["networkType"][] = [LTE, FEG_LTE, CWF, FEG];
if (!allowedNetworkTypes.includes((data.networkType))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace (data.networkType) with data.networkType

Suggested change
if (!allowedNetworkTypes.includes((data.networkType))) {
if (!allowedNetworkTypes.includes(data.networkType)) {

@moinuddin1980 moinuddin1980 force-pushed the topic/sec-issues/whitelisting-net-type branch from 05cd710 to dd7e5e4 Compare January 30, 2024 11:40
const allowedNetworkTypes = ['LTE', 'FEG_LTE', 'CWF', 'FEG'];

if (!allowedNetworkTypes.includes(data.networkType?.toUpperCase())) {
const allowedNetworkTypes: Array<typeof data['networkType']> = [LTE, FEG_LTE, CWF, FEG];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace LTE,·FEG_LTE,·CWF,·FEG with ⏎········LTE,⏎········FEG_LTE,⏎········CWF,⏎········FEG,⏎······

Suggested change
const allowedNetworkTypes: Array<typeof data['networkType']> = [LTE, FEG_LTE, CWF, FEG];
const allowedNetworkTypes: Array<typeof data['networkType']> = [
LTE,
FEG_LTE,
CWF,
FEG,
];

@moinuddin1980 moinuddin1980 force-pushed the topic/sec-issues/whitelisting-net-type branch from dd7e5e4 to af708ca Compare January 30, 2024 11:53
Signed-off-by: jahid-wavelabs <jahidul.mallick@wavelabs.ai>
@moinuddin1980 moinuddin1980 force-pushed the topic/sec-issues/whitelisting-net-type branch from af708ca to 42ba9db Compare January 31, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: nms NMS-related issue size/S Denotes a PR that changes 10-29 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant