Megosztás:


CodeQL-lekérdezések és -csomagok a Windows illesztőprogram-teszteléséhez

A Microsoft CodeQL GitHub-adattár két lekérdezéscsomagot kínál a Windows-illesztőprogramok fejlesztésének egyszerűsítéséhez és a Windows hardverkompatibilitási program (WHCP) megfelelőségének biztosításához. Az recommended.qls csomag tartalmazza az illesztőprogram-fejlesztők számára ajánlott összes lekérdezést, míg a mustfix.qls csomag a WHCP-minősítéshez szükséges "Must-Fix" lekérdezésekre összpontosít. Mindkét szoftvercsomag rendszeresen frissül.

Must-Fix WCHP-minősítéssel kapcsolatos lekérdezések

A lekérdezések alábbi részhalmaza a WHCP-tanúsítvány kötelező javítása , és az Ajánlott javítás csomag része is.

Ez a szabálykészlet a mustfix.qls része.

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/bad-addition-overflow-check codeql/cpp-queries/<Version>/Valószínű Hibák/Aritmetika/Rossz Összeadás Túlcsordulás Ellenőrzés.ql CWE-190, CWE-192
cpp/mutató-túlcsordulás-ellenőrzés codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/PointerOverflow.ql Nincs adat.
cpp/túl kevés argumentum codeql/cpp-queries/<Version>/Likely Bugs/Underspecified Functions/TooFewArguments.ql Nincs adat.
cpp/comparison-with-wider-type codeql/cpp-queries/<Version>/Security/CWE/CWE-190/ComparisonWithWiderType.ql CWE-190, CWE-197, CWE-835
cpp/hresult-boolean-conversion codeql/cpp-queries/<Version>/Security/CWE/CWE-253/HResultBooleanConversion.ql CWE-253

A mustfix.qls fájl a következő Must-Fix kód lekérdezéseket tartalmazza.

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

- description: Security queries required to fix when certifying Windows Drivers
- queries: .
  from: codeql/cpp-queries
  version: 0.9.0
- include:
    query path:
      - Likely Bugs/Arithmetic/BadAdditionOverflowCheck.ql
      - Likely Bugs/Memory Management/PointerOverflow.ql
      - Likely Bugs/Underspecified Functions/TooFewArguments.ql
      - Security/CWE/CWE-190/ComparisonWithWiderType.ql
      - Security/CWE/CWE-253/HResultBooleanConversion.ql
- import: windows-driver-suites/windows_mustfix_partial.qls
  from: microsoft/windows-drivers

Ezt a szabálykészletet a windows-driver-suites/windows_mustfix_partial.qls tartalmazza.

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/windows/wdk/elhagyott-api /microsoft/windows-drivers/<Version>/drivers/general/queries/WdkDeprecatedApis/wdk-deprecated-api.ql Nincs adat.
microsoft/Security/CWE/CWE-704/WcharCharConversionLimited /microsoft/windows-drivers/<Version>/microsoft/Security/CWE/CWE-704/WcharCharConversionLimited.ql CWE-704

A windows_mustfix_partial.qls fájl a következő Must-Fix kód lekérdezéseket tartalmazza.

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

- description: Security queries required to fix when certifying Windows Drivers
- queries: .
  from: microsoft/windows-drivers
- include:
    query path:
      - drivers/general/queries/WdkDeprecatedApis/wdk-deprecated-api.ql
      - microsoft/Security/CWE/CWE-704/WcharCharConversionLimited.ql

Ezek a lekérdezések a Microsoft GitHub CodeQL-adattárajánlott.qls lekérdezési csomagjának részei. A "Common Weakness Enumeration" (CWE) oszlop azonosítja, hogy az adott lekérdezés milyen biztonsági problémákat keres. A CWE-ről további információt Mitre CWE-oldalán talál.

A "Common Weakness Enumeration" (CWE) oszlop a lekérdezés által azonosított biztonsági problémák típusait mutatja.

Ajánlott eljárások

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/eltolás-használat-a-tartomány-ellenőrzés-előtt codeql/cpp-queries/<Version>/Ajánlott eljárások/Valószínű hibák/OffsetUseBeforeRangeCheck.ql Nincs adat.

Valószínű hibák

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/bad-addition-overflow-check codeql/cpp-queries/<Version>/Valószínű Hibák/Aritmetika/Rossz Összeadás Túlcsordulás Ellenőrzés.ql CWE-190, CWE-192
cpp/egész-szám-szorzás-hosszúvá-kasztolás codeql/cpp-queries/<Version>/Likely Bugs/Arithmetic/IntMultToLong.ql CWE-190, CWE-192, CWE-197, CWE-681
cpp/signed-overflow-check codeql/cpp-queries/<Version>/Likely Bugs/Arithmetic/SignedOverflowCheck.ql Nincs adat.
cpp/upcast-array-pointer-aritmetic codeql/cpp-queries/<Version>/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql CWE-119, CWE-843
cpp/mutató-túlcsordulás-ellenőrzés codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/PointerOverflow.ql Nincs adat.
cpp/túl kevés argumentum codeql/cpp-queries/<Version>/Likely Bugs/Underspecified Functions/TooFewArguments.ql Nincs adat.
cpp/helytelen nem operátorhasználat codeql/cpp-queries/<Version>/Valószínű Hibák/Valószínű Elgépelések/HelytelenNemOperátorHasználat.ql CWE-480
cpp/suspicious-add-sizeof codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/SuspiciousSizeof.ql CWE-468
cpp/uninitialized-local codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/UninitializedLocal.ql CWE-457, CWE-665

Biztonság

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/feltételesen inicializálatlan változó codeql/cpp-queries/<Version>/Security/CWE/CWE-457/ConditionallyUninitializedVariable.ql. CWE-457
cpp/befejezetlen variádikus hívás codeql/cpp-queries/<Version>/Security/CWE/CWE-121/UnterminatedVarargsCall.ql CWE-121
cpp/gyanús-mutató-skálázás codeql/cpp-queries/<Version>/Security/CWE/CWE-468/IncorrectPointerScaling.ql CWE-468
cpp/suspicious-pointer-scaling-void codeql/cpp-queries/<Version>/Security/CWE/CWE-468/IncorrectPointerScalingVoid.ql CWE-468
cpp/potenciálisan veszélyes függvény codeql/cpp-queries/<Version>/Security/CWE/CWE-676/PotentiallyDangerousFunction.ql CWE-676
cpp/helytelen-karakterlánc-típus-konverzió codeql/cpp-queries/<Version>/Security/CWE/CWE-704/WcharCharConversion.ql CWE-704
cpp/comparison-with-wider-type codeql/cpp-queries/<Version>/Security/CWE/CWE-190/ComparisonWithWiderType.ql CWE-190, CWE-197, CWE-835
cpp/hresult-boolean-conversion codeql/cpp-queries/<Version>/Security/CWE/CWE-253/HResultBooleanConversion.ql CWE-253
cpp/suspicious-add-sizeof codeql/cpp-queries/<Version>/Security/CWE/CWE-468/CWE-468/SuspiciousAddWithSizeof.ql CWE-468

Az recommended.qls fájl az alábbi ajánlott kód lekérdezéseket tartalmazza.

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

- description: Recommended and required queries for Windows Drivers.
- import: windows-driver-suites/windows_mustfix_partial.qls
  from: microsoft/windows-drivers
- import: windows-driver-suites/windows_recommended_partial.qls
  from: microsoft/windows-drivers
- queries: .
  from: codeql/cpp-queries
  version: 0.9.0
- include:
    query path:
      - Best Practices/Likely Errors/OffsetUseBeforeRangeCheck.ql
      - Likely Bugs/Arithmetic/IntMultToLong.ql
      - Likely Bugs/Arithmetic/SignedOverflowCheck.ql
      - Likely Bugs/Conversion/CastArrayPointerArithmetic.ql
      - Likely Bugs/Likely Typos/IncorrectNotOperatorUsage.ql
      - Likely Bugs/Memory Management/SuspiciousSizeof.ql
      - Likely Bugs/Memory Management/UninitializedLocal.ql
      - Security/CWE/CWE-121/UnterminatedVarargsCall.ql
      - Security/CWE/CWE-457/ConditionallyUninitializedVariable.ql
      - Security/CWE/CWE-468/IncorrectPointerScaling.ql
      - Security/CWE/CWE-468/IncorrectPointerScalingVoid.ql
      - Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql
      - Security/CWE/CWE-676/PotentiallyDangerousFunction.ql
      - Security/CWE/CWE-704/WcharCharConversion.ql
      - Likely Bugs/Arithmetic/BadAdditionOverflowCheck.ql
      - Likely Bugs/Memory Management/PointerOverflow.ql
      - Likely Bugs/Underspecified Functions/TooFewArguments.ql
      - Security/CWE/CWE-190/ComparisonWithWiderType.ql
      - Security/CWE/CWE-253/HResultBooleanConversion.ql

Ezek a lekérdezések a windows_recommended_partial.qls lekérdezési csomag részét képezik.

azonosító Elhelyezkedés Gyakori gyengeségek számbavétele
cpp/padding byte információ kiszivárogtatás microsoft/windows-drivers/<Version>/microsoft/Lehetséges hibák/Határátlépések/Tömítőbájt-adatközlés.ql Nincs adat.
cpp/badoverflowguard microsoft/windows-drivers/<Version>/microsoft/Valószínű hibák/Átalakítás/BadOverflowGuard.ql Nincs adat.
cpp/infiniteloop microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Conversion/InfiniteLoop.ql Nincs adat.
cpp/uninitializedptrfield microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/UninitializedPtrField.ql Nincs adat.
cpp/használat után ingyenes microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Memory Management/UseAfterFree/UseAfterFree.ql Nincs adat.
azonosító Elhelyezkedés Kódelemzési figyelmeztetés
cpp/weak-crypto/cng/hardcoded-iv /microsoft/windows-drivers/<Version>/microsoft/Security/Cryptography/HardcodedIVCNG.ql Nincs adat.

Illesztőprogramok – Általános

azonosító Elhelyezkedés Kódelemzési figyelmeztetés
cpp/drivers/ke-set-event-pageable /microsoft/windows-drivers/<Version>/drivers/general/queries/KeSetEventPageable/KeSetEventPageable.ql Nincs társított CA ellenőrzés
cpp/drivers/helyesen használt szereptípus /microsoft/windows-drivers/<Version>/drivers/general/queries/RoleTypeCorrectlyUsed/RoleTypeCorrectlyUsed.ql Nincs társított CA ellenőrzés
cpp/drivers/extended-deprecated-apis /microsoft/windows-drivers/<Version>/drivers/general/queries/ExtendedDeprecatedApis.ql C28719 Warning, C28726 Warning, C28735 Warning, C28750 Warning
cpp/drivers/irql-not-saved /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlNotSaved/IrqlNotSaved.ql C28158 figyelmeztetés
cpp/drivers/irql-not-used /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlNotUsed/IrqlNotUsed.ql C28157 figyelmeztetés
cpp/drivers/irql-túl-magasra-állítva /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlTooHigh/IrqlTooHigh.ql C28150 figyelmeztetés
cpp/drivers/irql-too-low /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlTooLow/IrqlTooLow.ql C28120 figyelmeztetés
cpp/drivers/irql-túl-magasra-állítva /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlSetTooHigh/IrqlTooHigh.ql C28121 figyelmeztetés
cpp/drivers/irql-set-too-low /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlSetTooLow/IrqlSetTooLow.ql C28124 figyelmeztetés
cpp/drivers/pool-tag-integral /microsoft/windows-drivers/<Version>/drivers/general/queries/PoolTagIntegral/PoolTagIntegral.ql C28134 figyelmeztetés
cpp/drivers/str-safe /microsoft/windows-drivers/<Version>/drivers/general/queries/StrSafe/StrSafe.ql C28146 figyelmeztetés

Illesztőprogramok – WDM

azonosító Elhelyezkedés Kódelemzési figyelmeztetés
cpp/illesztőprogramok/illegális-mezei-hozzáférés /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldAccess/IllegalFieldAccess.ql C28128 figyelmeztetés
cpp/drivers/illegal-field-access2 /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldAccess2/IllegalFieldAccess2.ql C28175 figyelmeztetés
cpp/illesztők/illegális-mező-írás /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldWrite/IllegalFieldWrite.ql C28176 figyelmeztetés
cpp/drivers/opaque-mdl-use /microsoft/windows-drivers/<Version>/drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlUse.ql (Nincs társított hitelesítésszolgáltatói ellenőrzés)
cpp/drivers/opaque-mdl-write /microsoft/windows-drivers/<Version>/drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlWrite.ql C28145 figyelmeztetés
cpp/drivers/függő-státusz-hiba /microsoft/windows-drivers/<Version>/drivers/wdm/queries/PendingStatusError/PendingStatusError.ql C28143 figyelmeztetés
cpp/meghajtók/hibás-diszpécstábla-hozzárendelés /microsoft/windows-drivers/<Version>/drivers/wdm/queries/WrongDispatchTableAssignment/WrongDispatchTableAssignment.ql C28169 figyelmeztetés

A windows-driver-suites/windows_recommended_partial.qls fájl az alábbi ajánlott kód lekérdezéseket tartalmazza.

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

- description: Recommended and required queries for Windows Drivers.
- import: windows-driver-suites/windows_mustfix_partial.qls
- queries: .
  from: microsoft/windows-drivers
- include:
    query path:
      - microsoft/Likely Bugs/Boundary Violations/PaddingByteInformationDisclosure.ql
      - microsoft/Likely Bugs/Conversion/BadOverflowGuard.ql
      - microsoft/Likely Bugs/Conversion/InfiniteLoop.ql
      - microsoft/Likely Bugs/Memory Management/UseAfterFree/UseAfterFree.ql
      - microsoft/Likely Bugs/UninitializedPtrField.ql
      - microsoft/Security/Crytpography/HardcodedIVCNG.ql
      - drivers/general/queries/KeSetEventPageable/KeSetEventPageable.ql
      - drivers/general/queries/RoleTypeCorrectlyUsed/RoleTypeCorrectlyUsed.ql
      - drivers/general/queries/DefaultPoolTag/DefaultPoolTag.ql
      - drivers/general/queries/ExaminedValue/ExaminedValue.ql
      - drivers/general/queries/ExtendedDeprecatedApis/ExtendedDeprecatedApis.ql
      - drivers/general/queries/IrqlNotSaved/IrqlNotSaved.ql
      - drivers/general/queries/IrqlNotUsed/IrqlNotUsed.ql
      - drivers/general/queries/IrqlTooHigh/IrqlTooHigh.ql
      - drivers/general/queries/IrqlTooLow/IrqlTooLow.ql
      - drivers/general/queries/IrqlSetTooHigh/IrqlTooHigh.ql
      - drivers/general/queries/IrqlSetTooLow/IrqlSetTooLow.ql
      - drivers/general/queries/PoolTagIntegral/PoolTagIntegral.ql
      - drivers/general/queries/StrSafe/StrSafe.ql
      - drivers/wdm/queries/IllegalFieldAccess/IllegalFieldAccess.ql
      - drivers/wdm/queries/IllegalFieldAccess2/IllegalFieldAccess2.ql
      - drivers/wdm/queries/IllegalFieldWrite/IllegalFieldWrite.ql
      - drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlUse.ql
      - drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlWrite.ql
      - drivers/wdm/queries/PendingStatusError/PendingStatusError.ql
      - drivers/wdm/queries/WrongDispatchTableAssignment/WrongDispatchTableAssignment.ql