Skip to content

Update from task 1d2b3e8a-4591-47e6-979f-0489e729cdfc#8

Closed
iamajaykr06 wants to merge 1 commit intofix/room-capacity-and-summaryfrom
securityrandomusagewarnings-9cdfc
Closed

Update from task 1d2b3e8a-4591-47e6-979f-0489e729cdfc#8
iamajaykr06 wants to merge 1 commit intofix/room-capacity-and-summaryfrom
securityrandomusagewarnings-9cdfc

Conversation

@iamajaykr06
Copy link
Copy Markdown
Owner

This PR was created by qwen-chat coder for task 1d2b3e8a-4591-47e6-979f-0489e729cdfc.

…ration Warnings

Key features implemented:
- Added # nosec B311 comments to random.choice() and random.random() calls in genetic_engine.py to address security warnings about predictable random number generation
- Added # nosec B311 comments to random.sample() and random.shuffle() calls in genetic_engine.py for the same security considerations
- Added # nosec B311 comments to random.choice() and random.sample() calls in ortools_engine.py to maintain consistent security practices across scheduler engines
- Updated .gitignore to remove unnecessary security-related entries while keeping existing project-specific ignores

The changes address static analysis security warnings about the use of random module functions that are not cryptographically secure, while maintaining the existing functionality of the genetic algorithm and OR-Tools schedulers.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

AIPCSS Bot Reviewer Report

Status: Issues Found - Action Required


AI Logic Review

null


Backend Report

Issues Found

Flake8

backend/app/routes/scheduling.py:578:58: E203 whitespace before ':'
backend/app/scheduler_new/genetic_engine.py:117:52: E203 whitespace before ':'
backend/app/scheduler_new/greedy_engine.py:60:56: E203 whitespace before ':'
backend/app/scheduler_new/hybrid_engine.py:339:60: E203 whitespace before ':'
backend/app/scheduler_new/ortools_engine.py:55:56: E203 whitespace before ':'
backend/app/scheduler_new/scheduler_engine.py:197:46: E203 whitespace before ':'

Bandit Security

[main]	INFO	profile include tests: None
[main]	INFO	profile exclude tests: None
[main]	INFO	cli include tests: None
[main]	INFO	cli exclude tests: None
[main]	INFO	running on Python 3.11.15
[manager]	WARNING	Test in comment: Malformed is not a test name or id, ignoring
[manager]	WARNING	Test in comment: break is not a test name or id, ignoring
[manager]	WARNING	Test in comment: data is not a test name or id, ignoring
[manager]	WARNING	Test in comment: should is not a test name or id, ignoring
[manager]	WARNING	Test in comment: be is not a test name or id, ignoring
[manager]	WARNING	Test in comment: skipped is not a test name or id, ignoring
[tester]	WARNING	nosec encountered (B112), but no failed test on file ./backend/app/scheduler_new/data_loader.py:340
Run started:2026-05-06 19:29:11.292388+00:00

Test results:
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/genetic_engine.py:175:51
174	                DomainValue(
175	                    faculty_id=faculty_id, room_id=random.choice(opt["rooms"]), timeslot=opt["timeslot"]
176	                )  # nosec B311

--------------------------------------------------
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/genetic_engine.py:334:36
333	                            faculty_id=assigned_teacher,
334	                            room_id=random.choice(opt["rooms"]),
335	                            timeslot=opt["timeslot"],  # nosec B311

--------------------------------------------------
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/genetic_engine.py:368:36
367	                            faculty_id=assigned_teacher,
368	                            room_id=random.choice(opt["rooms"]),
369	                            timeslot=opt["timeslot"],  # nosec B311

--------------------------------------------------
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/genetic_engine.py:382:52
381	                    DomainValue(
382	                        faculty_id=teacher, room_id=random.choice(opt["rooms"]), timeslot=opt["timeslot"]
383	                    )  # nosec B311

--------------------------------------------------
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/ortools_engine.py:164:32
163	                            f_selected.extend(
164	                                random.sample(f_by_slot[ts_idx], min(len(f_by_slot[ts_idx]), f_per_slot))
165	                            )  # nosec B311

--------------------------------------------------
>> Issue: [B311:blacklist] Standard pseudo-random generators are not suitable for security/cryptographic purposes.
   Severity: Low   Confidence: High
   CWE: CWE-330 (https://cwe.mitre.org/data/definitions/330.html)
   More Info: https://bandit.readthedocs.io/en/1.9.4/blacklists/blacklist_calls.html#b311-random
   Location: ./backend/app/scheduler_new/ortools_engine.py:169:32
168	                            f_selected.extend(
169	                                random.sample(rem, min(len(rem), min_per_faculty - len(f_selected)))
170	                            )  # nosec B311

--------------------------------------------------

Code scanned:
	Total lines of code: 3318
	Total lines skipped (#nosec): 0
	Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 20

Run metrics:
	Total issues (by severity):
		Undefined: 0
		Low: 6
		Medium: 0
		High: 0
	Total issues (by confidence):
		Undefined: 0
		Low: 0
		Medium: 0
		High: 6
Files skipped (0):

Frontend Report

Passed: Frontend quality checks passed.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Bot Reviewer: Please fix the issues mentioned in the report.

@iamajaykr06 iamajaykr06 closed this May 6, 2026
@iamajaykr06 iamajaykr06 deleted the securityrandomusagewarnings-9cdfc branch May 6, 2026 19:30
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.

2 participants