Aracılığıyla paylaş


Windows Sürücü Testi için CodeQL Sorguları ve Paketleri

Microsoft CodeQL GitHub deposu, Windows sürücü geliştirmeyi basitleştirmek ve Windows Donanım Uyumluluk Programı (WHCP) ile uyumluluğu sağlamak için iki sorgu paketi sunar. recommended.qls paketi sürücü geliştiricileri için önerilen tüm sorguları içerirken mustfix.qls paketi WHCP sertifikası için gereken "Düzeltilmesi Gereken" sorgulara odaklanır. Her iki paket de düzenli olarak güncelleştirilir.

WCHP sertifikası için Must-Fix sorguları

Aşağıdaki sorgu alt kümesi WHCP sertifikası için Düzeltilmelidir ve Önerilen Düzeltme paketine de eklenmiştir.

Bu kural kümesi mustfix.qls dosyasına dahildir.

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/kötü-toplama-taşma-kontrolü codeql/cpp-queries/<Version>/Likely Bugs/Arithmetic/BadAdditionOverflowCheck.ql CWE-190, CWE-192
cpp/pointer-overflow-check codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/PointerOverflow.ql Mevcut Değil
cpp/çok az bağımsız değişken codeql/cpp-queries/<Version>/Likely Bugs/Underspecified Functions/TooFewArguments.ql Mevcut Değil
cpp/geniş türle karşılaştırma 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

mustfix.qls dosyası aşağıdaki Düzeltilmesi Gereken kod sorgularını içerir.

# 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

Bu kural kümesi windows-driver-suites/windows_mustfix_partial.qls dosyasına dahildir.

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/windows/wdk/deprecated-api /microsoft/windows-drivers/<Version>/drivers/general/queries/WdkDeprecatedApis/wdk-deprecated-api.ql Mevcut Değil
microsoft/Security/CWE/CWE-704/WcharCharConversionLimited /microsoft/windows-drivers/<Version>/microsoft/Security/CWE/CWE-704/WcharCharConversionLimited.ql CWE-704

windows_mustfix_partial.qls dosyası aşağıdaki Düzeltilmesi Gereken kod sorgularını içerir.

# 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

Bu sorgular, Microsoft GitHub CodeQL deposundakirecommended.qls sorgu paketinin bir parçasıdır. "Ortak Zayıflık Numaralandırması" (CWE) sütunu, verilen sorgunun hangi tür güvenlik sorunları için arama yaptığını tanımlar. CWE'ler hakkında daha fazla bilgi için CWE'de Mitre'nin sayfasına bakın.

"Ortak Zayıflık Numaralandırması" (CWE) sütunu, sorgunun tanımlamış olduğu güvenlik sorunlarının türlerini gösterir.

En İyi Yöntemler

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/aralık-kontrolü-öncesi-ofset-kullanımı codeql/cpp-queries/<Version>/Best Practices/Likely Errors/OffsetUseBeforeRangeCheck.ql Mevcut Değil

Olası Hatalar

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/kötü-toplama-taşma-kontrolü codeql/cpp-queries/<Version>/Likely Bugs/Arithmetic/BadAdditionOverflowCheck.ql CWE-190, CWE-192
cpp/tamsayı-çarpmayı-uzun-tipe-dönüştürme 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 Mevcut Değil
cpp/upcast-array-pointer-aritmetic codeql/cpp-queries/<Version>/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql CWE-119, CWE-843
cpp/pointer-overflow-check codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/PointerOverflow.ql Mevcut Değil
cpp/çok az bağımsız değişken codeql/cpp-queries/<Version>/Likely Bugs/Underspecified Functions/TooFewArguments.ql Mevcut Değil
cpp/incorrect-not-operator-usage codeql/cpp-queries/<Version>/Muhtemel Hatalar/Muhtemel Yazım Hataları/Yanlış Değil Operatörü Kullanımı.ql CWE-480
cpp/suspicious-add-sizeof codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/SuspiciousSizeof.ql CWE-468
cpp/başlatılmamış-yerel codeql/cpp-queries/<Version>/Likely Bugs/Memory Management/UninitializedLocal.ql CWE-457, CWE-665

Güvenlik

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/koşullu olarak başlatılmamış-değişken codeql/cpp-queries/<Version>/Security/CWE/CWE-457/ConditionallyUninitializedVariable.ql. CWE-457
cpp/unterminated-variadic-call codeql/cpp-queries/<Version>/Security/CWE/CWE-121/UnterminatedVarargsCall.ql CWE-121
cpp/suspicious-pointer-scaling codeql/cpp-queries/<Version>/Security/CWE/CWE-468/IncorrectPointerScaling.ql CWE-468
cpp/şüpheli-işaretçi-ölçekleme-boş codeql/cpp-queries/<Version>/Security/CWE/CWE-468/IncorrectPointerScalingVoid.ql CWE-468
cpp/potansiyel-tehlikeli-işlev codeql/cpp-queries/<Version>/Security/CWE/CWE-676/PotentiallyDangerousFunction.ql CWE-676
cpp/incorrect-string-type-conversion codeql/cpp-queries/<Version>/Security/CWE/CWE-704/WcharCharConversion.ql CWE-704
cpp/geniş türle karşılaştırma 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

Recommended.qls dosyası aşağıdaki önerilen kod sorgularını içerir.

# 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

Bu sorgular windows_recommended_partial.qls sorgu paketinin bir parçasıdır.

Kimlik Yer Ortak Zayıflık Numaralandırması
cpp/paddingbyteinformationdisclosure microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Boundary Violations/PaddingByteInformationDisclosure.ql Mevcut Değil
cpp/badoverflowguard microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Conversion/BadOverflowGuard.ql Mevcut Değil
cpp/infiniteloop microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Conversion/InfiniteLoop.ql Mevcut Değil
cpp/uninitializedptrfield microsoft/windows-drivers//<Version>microsoft/Likely Bugs/UninitializedPtrField.ql Mevcut Değil
cpp/kullanımdan sonra microsoft/windows-drivers/<Version>/microsoft/Likely Bugs/Memory Management/UseAfterFree/UseAfterFree.ql Mevcut Değil
Kimlik Yer Kod Analizi Uyarısı
cpp/weak-crypto/cng/hardcoded-iv /microsoft/windows-drivers/<Version>/microsoft/Security/Crytpography/HardcodedIVCNG.ql Mevcut Değil

Sürücüler - Genel

Kimlik Yer Kod Analizi Uyarısı
cpp/drivers/ke-set-event-pageable /microsoft/windows-drivers/<Version>/drivers/general/queries/KeSetEventPageable/KeSetEventPageable.ql İlişkili CA denetimi yok
cpp/drivers/role-type-correct-used /microsoft/windows-drivers/<Version>/drivers/general/queries/RoleTypeCorrectlyUsed/RoleTypeCorrectlyUsed.ql İlişkili CA denetimi yok
cpp/drivers/extended-deprecated-apis /microsoft/windows-drivers/<Version>/drivers/general/queries/ExtendedDeprecatedApis.ql C28719 Uyarısı, C28726 Uyarısı, C28735 Uyarısı, C28750 Uyarısı
cpp/drivers/irql-not-saved /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlNotSaved/IrqlNotSaved.ql C28158 Uyarısı
cpp/drivers/irql-not-used /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlNotUsed/IrqlNotUsed.ql C28157 Uyarısı
cpp/drivers/irql-set-too-high /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlTooHigh/IrqlTooHigh.ql C28150 Uyarısı
cpp/drivers/irql-too-low /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlTooLow/IrqlTooLow.ql C28120 Uyarısı
cpp/drivers/irql-set-too-high /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlSetTooHigh/IrqlTooHigh.ql C28121 Uyarısı
cpp/drivers/irql-set-too-low /microsoft/windows-drivers/<Version>/drivers/general/queries/IrqlSetTooLow/IrqlSetTooLow.ql C28124 Uyarısı
cpp/drivers/pool-tag-integral /microsoft/windows-drivers/<Version>/drivers/general/queries/PoolTagIntegral/PoolTagIntegral.ql C28134 Uyarısı
cpp/drivers/str-safe /microsoft/windows-drivers/<Version>/drivers/general/queries/StrSafe/StrSafe.ql C28146 Uyarısı

Sürücüler - WDM

Kimlik Yer Kod Analizi Uyarısı
cpp/drivers/illegal-field-access /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldAccess/IllegalFieldAccess.ql C28128 Uyarısı
cpp/drivers/illegal-field-access2 /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldAccess2/IllegalFieldAccess2.ql C28175 Uyarısı
cpp/drivers/illegal-field-write /microsoft/windows-drivers/<Version>/drivers/wdm/queries/IllegalFieldWrite/IllegalFieldWrite.ql C28176 Uyarısı
cpp/drivers/opaque-mdl-use /microsoft/windows-drivers/<Version>/drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlUse.ql (İlişkili CA denetimi yok)
cpp/drivers/opaque-mdl-write /microsoft/windows-drivers/<Version>/drivers/wdm/queries/OpaqueMdlUse/OpaqueMdlWrite.ql C28145 Uyarısı
cpp/drivers/pending-status-error /microsoft/windows-drivers/<Version>/drivers/wdm/queries/PendingStatusError/PendingStatusError.ql C28143 Uyarısı
cpp/drivers/wrong-dispatch-table-assignment /microsoft/windows-drivers/<Version>/drivers/wdm/queries/WrongDispatchTableAssignment/WrongDispatchTableAssignment.ql C28169 Uyarısı

windows-driver-suites/windows_recommended_partial.qls dosyası aşağıdaki önerilen kod sorgularını içerir.

# 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