Repository navigation
Commit ef1b6e2
committed
fix(pe2): cover setgid and world-writable numeric chmod modes
Review of #678 found three coverage gaps against main's behaviour, all
reproduced before fixing:
- [4567] only selected setuid. A leading 2 or 3 sets setgid, which escalates
an executable the same way because it then runs with the file's group, so
`chmod 2755`/`chmod 3755` were reported on main and on this head by
nothing. Use [2-7]; a bare leading 1 only adds sticky, which grants nobody
new access, and stays unreported.
- The terminator allowlist (?=\s|$|[;&|]) dropped valid spellings that main
caught: leading zeros (chmod 04755, chmod 006755), and terminators such
as a backtick, `)`, or ${IFS}. Accept 0* before the special digit and
replace the allowlist with a trailing (?![0-9\w]) lookahead, which needs
no allowlist and still rejects chmod 47554.
- Requiring the leading digit also un-reported every world-writable numeric
mode whose spelling does not contain a literal 777/666, so `chmod 646
/etc/sudoers` and `chmod 757 ...` were reported on main and on this head by
no static pattern. Widen TM1, which already owned the literal 777/666
spellings, to any numeric mode whose others-triple carries the write bit
(last digit 2, 3, 6 or 7). Anchoring on the mode argument also stops a
777/666 substring inside a later path or comment from being read as the
mode. PE2 is "Sudo/Root Execution" and a world-writable file grants access
to every user rather than to root, so the finding keeps its existing home.
Also allow an option before the mode (chmod -R 4755 dir), which was missed
before this change too, with negative cases proving the option group does not
let a restrictive mode through.
Reverting any one of the eight regex elements turns at least one test red;
each was checked individually.
Signed-off-by: Yi-111-a <[email protected]>1 parent 5e599f8 commit ef1b6e2
3 files changed
Lines changed: 104 additions & 6 deletions
File tree
- src/skillspector/nodes/analyzers
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
216 | 224 | | |
217 | 225 | | |
218 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
1390 | 1393 | | |
1391 | 1394 | | |
1392 | 1395 | | |
1393 | | - | |
1394 | | - | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1395 | 1399 | | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
1396 | 1404 | | |
1397 | 1405 | | |
1398 | 1406 | | |
1399 | 1407 | | |
1400 | 1408 | | |
1401 | | - | |
| 1409 | + | |
1402 | 1410 | | |
1403 | 1411 | | |
1404 | 1412 | | |
| |||
1407 | 1415 | | |
1408 | 1416 | | |
1409 | 1417 | | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
1410 | 1422 | | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1411 | 1437 | | |
1412 | 1438 | | |
1413 | 1439 | | |
| |||
1421 | 1447 | | |
1422 | 1448 | | |
1423 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
1424 | 1504 | | |
1425 | 1505 | | |
1426 | 1506 | | |
| |||
0 commit comments