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

Database #6

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

Database #6

wants to merge 29 commits into from

Conversation

yaredtsy
Copy link
Collaborator

@yaredtsy yaredtsy commented Feb 3, 2023

src/database/index.ts Fixed Show fixed Hide fixed
src/database/index.ts Fixed Show fixed Hide fixed
src/database/index.ts Fixed Show fixed Hide fixed
src/database/index.ts Fixed Show fixed Hide fixed
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

ESLint found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

};

const findUserByEmail = async (email: string): Promise<User | null> => {
const user = await UserModel.findOne({ email: email });

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1).
app.use(morgan('tiny'));
app.use(cors({ origin: corsUrl, optionsSuccessStatus: 200 }));

app.use(
session({
secret: 'secret',

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "secret" is used as [key](1).
@@ -1,8 +1,17 @@
export const environment = process.env.NODE_ENV;
export const port = process.env.PORT || 5000;
export const timezone = process.env.TZ;
export const SECRET_KEY = process.env.SECRET_KEY || 'secret';

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "secret" is used as [key](1).
}
const updatedPermissions = await PermissionsModel.findByIdAndUpdate(
_id,
{ action, resource, attributes: attributes || '*' },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1).
role.permissions = permissions;

try {
const updateRole = await RoleModel.findByIdAndUpdate(id, role, {

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1).

router.post('/register', validator(schema.registerUserSchema), Register);

router.get('/logout', ProtectRoutes, Logout);

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
Comment on lines +35 to +43
session({
secret: 'secret',
resave: false,
saveUninitialized: true,
store: sessionStore,
cookie: {
maxAge: 1000 * 60 * 60 * 24
}
})

Check warning

Code scanning / CodeQL

Clear text transmission of sensitive cookie

Sensitive cookie sent without enforcing SSL encryption.
Comment on lines +35 to +43
session({
secret: 'secret',
resave: false,
saveUninitialized: true,
store: sessionStore,
cookie: {
maxAge: 1000 * 60 * 60 * 24
}
})

Check failure

Code scanning / CodeQL

Missing CSRF middleware

This cookie middleware is serving a [request handler](1) without CSRF protection.
};

const findRoleById = async (id: Types.ObjectId): Promise<Role | null> => {
const role = await RoleModel.findOne({ _id: id }).lean().exec();

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1).
};

const getRoleByName = async (roleName: string) => {
const role = await RoleModel.findOne({ roleName: roleName });

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1). This query depends on a [user-provided value](2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant