Skip to content

[vendored] CDStructures.h lacks an include guard and is auto-generated from class-dump — please publish a maintained hand-written copy #1187

Description

@dariusta

Source

Filed from a downstream consumer (Straton-Labs-LLC/stratton-internal, vendoring WebDriverAgentLib.xcframework).
Tracking ID in our audit: ocr-prelim-06853 (include guard) and ocr-prelim-05697 (runtime-validate inputs subset).

Affected file

WebDriverAgentLib/RodmanRunnerLib/CDStructures.h (vendored header at native/runner/Frameworks/WebDriverAgentLib.xcframework/ios-arm64/RodmanRunnerLib.framework/Headers/CDStructures.h)

Current contents (verbatim)

//
//     Generated by class-dump 3.5 (64 bit).
//
//     class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//

#pragma mark Blocks

typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown

typedef struct {
    unsigned int _field1;
    unsigned int _field2;
    unsigned int _field3;
    unsigned int _field4;
    unsigned int _field5;
    unsigned int _field6;
    unsigned int _field7;
} CDStruct_a561fd19;

typedef struct {
    unsigned short _field1;
    unsigned short _field2;
    unsigned short _field3[1];
} CDStruct_27a325c0;

int _XCTSetApplicationStateTimeout(double timeout);
double _XCTApplicationStateTimeout(void);

Defects

  1. No include guard. The file declares a typedef with the same name as one already declared by XCTest private interfaces (CDUnknownBlockType). Consumers that include both this header and XCTest/XCTest.h get Typedef redefinition errors under -Werror. The Xcode module map for XCTest does not export the same name, but preprocessor concatenation from a third-party header will.
  2. Auto-generated, never regenerated. The banner Generated by class-dump 3.5 (64 bit) is preserved verbatim. There is no source-of-truth .xcconfig or build phase that regenerates this header from the current Xcode toolchain, so the types drift silently as Apple's private XCTest symbols change. We have observed _XCTApplicationStateTimeout disappearing on Xcode 16.x and the typedefs above it shifting widths.
  3. Inputs declared opaque. _XCTSetApplicationStateTimeout(double) and _XCTApplicationStateTimeout(void) accept no nullability annotations, no min/max bounds, and no NS_REFINED_FOR_SWIFT annotation. Downstream callers cannot validate their arguments before invoking, which is the underlying defect behind ocr-prelim-05697 ("runtime-validate inputs consumed by CDStructures.h").

Suggested fix

  1. Wrap the file in an include guard and a Foundation import:
    #import <Foundation/Foundation.h>
    
    #ifndef RODMAN_RUNNER_LIB_CD_STRUCTURES_H
    #define RODMAN_RUNNER_LIB_CD_STRUCTURES_H
    
    #pragma mark Blocks
    
    typedef void (^CDUnknownBlockType)(void);
    
    // ... struct decls ...
    
    #endif /* RODMAN_RUNNER_LIB_CD_STRUCTURES_H */
  2. Move the struct field names from _field1/_field2 to semantic names where the underlying class-dump source has revealed them (e.g. _XCTestCaseImplementation's ivars map to XCTestCase *testCase, NSDate *startDate, etc.). For fields that are still opaque after class-dump, leave them as _field1 but document why and what they are inferred to hold.
  3. For the two C functions, add nullability + bounds:
    NS_ASSUME_NONNULL_BEGIN
    int _XCTSetApplicationStateTimeout(double timeout);  // timeout > 0
    double _XCTApplicationStateTimeout(void) NS_RETURNS_NOT_REFINED;
    NS_ASSUME_NONNULL_END
  4. Add a script under WebDriverAgentLib/Tools/ that regenerates this header from class-dump and check it into CI so future Xcode bumps do not silently drift.

Why this matters downstream

We cannot regenerate this from the public SDK (XCTest private interfaces are not in the SDK), and we cannot fix the include-guard omission without forking the file. Pinning a maintained upstream version is the only durable fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions