Category: git

  • I’m learning about perlguts today.


    im-learning-about-perlguts-today.png


    ## 0.23	2025-12-20
    
    commit be15aa25dea40aea66a8534143fb81b29d2e6c08
    Author: C.J. Collier 
    Date:   Sat Dec 20 22:40:44 2025 +0000
    
        Fixes C-level test infrastructure and adds more test cases for upb_to_sv conversions.
        
        - **Makefile.PL:**
            - Allow `extra_src` in `c_test_config.json` to be an array.
            - Add ASan flags to CCFLAGS and LDDLFLAGS for better debugging.
            - Corrected echo newlines in `test_c` target.
        - **c_test_config.json:**
            - Added missing type test files to `deps` and `extra_src` for `convert/sv_to_upb` and `convert/upb_to_sv` test runners.
        - **t/c/convert/upb_to_sv.c:**
            - Fixed a double free of `test_pool`.
            - Added missing includes for type test headers.
            - Updated test plan counts.
        - **t/c/convert/sv_to_upb.c:**
            - Added missing includes for type test headers.
            - Updated test plan counts.
            - Corrected Perl interpreter initialization.
        - **t/c/convert/types/**:
            - Added missing `test_util.h` include in new type test headers.
            - Completed the set of `upb_to_sv` test cases for all scalar types by adding optional and repeated tests for `sfixed32`, `sfixed64`, `sint32`, and `sint64`, and adding repeated tests to the remaining scalar type files.
        - **Documentation:**
            - Updated `01-xs-testing.md` with more debugging tips, including ASan usage and checking for double frees and typos.
            - Updated `xs_learnings.md` with details from the recent segfault.
            - Updated `llm-plan-execution-instructions.md` to emphasize debugging steps.
    
    
    ## 0.22	2025-12-19
    
    commit 2c171d9a5027e0150eae629729c9104e7f6b9d2b
    Author: C.J. Collier 
    Date:   Fri Dec 19 23:41:02 2025 +0000
    
        feat(perl,testing): Initialize C test framework and build system
        
        This commit sets up the foundation for the C-level tests and the build system for the Perl Protobuf module:
        
        1.  **Makefile.PL Enhancements:**
            *   Integrates `Devel::PPPort` to generate `ppport.h` for better portability.
            *   Object files now retain their path structure (e.g., `xs/convert/sv_to_upb.o`) instead of being flattened, improving build clarity.
            *   The `MY::postamble` is significantly revamped to dynamically generate build rules for all C tests located in `t/c/` based on the `t/c/c_test_config.json` file.
            *   C tests are linked against `libprotobuf_common.a` and use `ExtUtils::Embed` flags.
            *   Added `JSON::MaybeXS` to `PREREQ_PM`.
            *   The `test` target now also depends on the `test_c` target.
        
        2.  **C Test Infrastructure (`t/c/`):
            *   Introduced `t/c/c_test_config.json` to configure individual C test builds, specifying dependencies and extra source files.
            *   Created `t/c/convert/test_util.c` and `.h` for shared test functions like loading descriptors.
            *   Initial `t/c/convert/upb_to_sv.c` and `t/c/convert/sv_to_upb.c` test runners.
            *   Basic `t/c/integration/030_protobuf_coro.c` for Coro safety testing on core utils using `libcoro`.
            *   Basic `t/c/integration/035_croak_test.c` for testing exception handling.
            *   Basic `t/c/integration/050_convert.c` for integration testing conversions.
        
        3.  **Test Proto:** Updated `t/data/test.proto` with more field types for conversion testing and regenerated `test_descriptor.bin`.
        
        4.  **XS Test Harness (`t/c/upb-perl-test.h`):** Added `like_n` macro for length-aware regex matching.
        
        5.  **Documentation:** Updated architecture and plan documents to reflect the C test structure.
        6.  **ERRSV Testing:** Note that the C tests (`t/c/`) will primarily check *if* a `croak` occurs (i.e., that the exception path is taken), but will not assert on the string content of `ERRSV`. Reliably testing `$@` content requires the full Perl test environment with `Test::More`, which will be done in the `.t` files when testing the Perl API.
        
        This provides a solid base for developing and testing the XS and C components of the module.
    
    
    ## 0.21	2025-12-18
    
    commit a8b6b6100b2cf29c6df1358adddb291537d979bc
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:20:47 2025 +0000
    
        test(C): Add integration tests for Milestone 2 components
        
        - Created t/c/integration/030_protobuf.c to test interactions
          between obj_cache, arena, and utils.
        - Added this test to t/c/c_test_config.json.
        - Verified that all C tests for Milestones 2 and 3 pass,
          including the libcoro-based stress test.
    
    
    ## 0.20	2025-12-18
    
    commit 0fcad68680b1f700a83972a7c1c48bf3a6958695
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:14:04 2025 +0000
    
        docs(plan): Add guideline review reminders to milestones
        
        - Added a "[ ] REFRESH: Review all documents in @perl/doc/guidelines/**"
          checklist item to the start of each component implementation
          milestone (C and Perl layers).
        - This excludes Integration Test milestones.
    
    
    ## 0.19	2025-12-18
    
    commit 987126c4b09fcdf06967a98fa3adb63d7de59a34
    Author: C.J. Collier 
    Date:   Thu Dec 18 04:05:53 2025 +0000
    
        docs(plan): Add C-level and Perl-level Coro tests to milestones
        
        - Added checklist items for `libcoro`-based C tests
          (e.g., `t/c/integration/050_convert_coro.c`) to all C layer
          integration milestones (050 through 220).
        - Updated `030_Integration_Protobuf.md` to standardise checklist
          items for the existing `030_protobuf_coro.c` test.
        - Removed the single `xt/author/coro-safe.t` item from
          `010_Build.md`.
        - Added checklist items for Perl-level `Coro` tests
          (e.g., `xt/coro/240_arena.t`) to each Perl layer
          integration milestone (240 through 400).
        - Created `perl/t/c/c_test_config.json` to manage C test
          configurations externally.
        - Updated `perl/doc/architecture/testing/01-xs-testing.md` to describe
          both C-level `libcoro` and Perl-level `Coro` testing strategies.
    
    
    ## 0.18	2025-12-18
    
    commit 6095a5a610401a6035a81429d0ccb9884d53687b
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:34:31 2025 +0000
    
        added coro testing to c layer milestones
    
    
    ## 0.17	2025-12-18
    
    commit cc0aae78b1f7f675fc8a1e99aa876c0764ea1cce
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:26:59 2025 +0000
    
        docs(plan): Refine test coverage checklist items for SMARTness
        
        - Updated the "Tests provide full coverage" checklist items in
          C layer plan files (020, 040, 060, 080, 100, 120, 140, 160, 180, 200)
          to explicitly mention testing all public functions in the
          corresponding header files.
        - Expanded placeholder checklists in 140, 160, 180, 200.
        - Updated the "Tests provide full coverage" and "Add coverage checks"
          checklist items in Perl layer plan files (230, 250, 270, 290, 310, 330,
          350, 370, 390) to be more specific about the scope of testing
          and the use of `Test::TestCoverage`.
        - Expanded Well-Known Types milestone (350) to detail each type.
    
    
    ## 0.16	2025-12-18
    
    commit e4b601f14e3817a17b0f4a38698d981dd4cb2818
    Author: C.J. Collier 
    Date:   Thu Dec 18 02:07:35 2025 +0000
    
        docs(plan): Full refactoring of C and Perl plan files
        
        - Split both ProtobufPlan-C.md and ProtobufPlan-Perl.md into
          per-milestone files under the `perl/doc/plan/` directory.
        - Introduced Integration Test milestones after each component
          milestone in both C and Perl plans.
        - Numbered milestone files sequentially (e.g., 010_Build.md,
          230_Perl_Arena.md).
        - Updated main ProtobufPlan-C.md and ProtobufPlan-Perl.md to
          act as Tables of Contents.
        - Ensured consistent naming for integration test files
          (e.g., `t/c/integration/030_protobuf.c`, `t/integration/260_descriptor_pool.t`).
        - Added architecture review steps to the end of all milestones.
        - Moved Coro safety test to C layer Milestone 1.
        - Updated Makefile.PL to support new test structure and added Coro.
        - Moved and split t/c/convert.c into t/c/convert/*.c.
        - Moved other t/c/*.c tests into t/c/protobuf/*.c.
        - Deleted old t/c/convert.c.
    
    
    ## 0.15	2025-12-17
    
    commit 649cbacf03abb5e7293e3038bb451c0406e9d0ce
    Author: C.J. Collier 
    Date:   Wed Dec 17 23:51:22 2025 +0000
    
        docs(plan): Refactor and reset ProtobufPlan.md
        
        - Split the plan into ProtobufPlan-C.md and ProtobufPlan-Perl.md.
        - Reorganized milestones to clearly separate C layer and Perl layer development.
        - Added more granular checkboxes for each component:
          - C Layer: Create test, Test coverage, Implement, Tests pass.
          - Perl Layer: Create test, Test coverage, Implement Module/XS, Tests pass, C-Layer adjustments.
        - Reset all checkboxes to `[ ]` to prepare for a full audit.
        - Updated status in architecture/api and architecture/core documents to "Not Started".
        
        feat(obj_cache): Add unregister function and enhance tests
        
        - Added `protobuf_unregister_object` to `xs/protobuf/obj_cache.c`.
        - Updated `xs/protobuf/obj_cache.h` with the new function declaration.
        - Expanded tests in `t/c/protobuf_obj_cache.c` to cover unregistering,
          overwriting keys, and unregistering non-existent keys.
        - Corrected the test plan count in `t/c/protobuf_obj_cache.c` to 17.
    
    
    ## 0.14	2025-12-17
    
    commit 40b6ad14ca32cf16958d490bb575962f88d868a1
    Author: C.J. Collier 
    Date:   Wed Dec 17 23:18:27 2025 +0000
    
        feat(arena): Complete C layer for Arena wrapper
        
        This commit finalizes the C-level implementation for the Protobuf::Arena wrapper.
        
        - Adds `PerlUpb_Arena_Destroy` for proper cleanup from Perl's DEMOLISH.
        - Enhances error checking in `PerlUpb_Arena_Get`.
        - Expands C-level tests in `t/c/protobuf_arena.c` to cover memory allocation
          on the arena and lifecycle through `PerlUpb_Arena_Destroy`.
        - Corrects embedded Perl initialization in the C test.
        
        docs(plan): Refactor ProtobufPlan.md
        
        - Restructures the development plan to clearly separate "C Layer" and
          "Perl Layer" tasks within each milestone.
        - This aligns the plan with the "C-First Implementation Strategy" and improves progress tracking.
    
    
    ## 0.13	2025-12-17
    
    commit c1e566c25f62d0ae9f195a6df43b895682652c71
    Author: C.J. Collier 
    Date:   Wed Dec 17 22:00:40 2025 +0000
    
        refactor(perl): Rename C tests and enhance Makefile.PL
        
        - Renamed test files in `t/c/` to better match the `xs` module structure:
            - `01-cache.c` -> `protobuf_obj_cache.c`
            - `02-arena.c` -> `protobuf_arena.c`
            - `03-utils.c` -> `protobuf_utils.c`
            - `04-convert.c` -> `convert.c`
            - `load_test.c` -> `upb_descriptor_load.c`
        - Updated `perl/Makefile.PL` to reflect the new test names in `MY::postamble`'s `$c_test_config`.
        - Refactored the `$c_test_config` generation in `Makefile.PL` to reduce repetition by using a default flags hash and common dependencies array.
        - Added a `fail()` macro to `perl/t/c/upb-perl-test.h` for consistency.
        - Modified `t/c/upb_descriptor_load.c` to use the `t/c/upb-perl-test.h` macros, making its output consistent with other C tests.
        - Added a skeleton for `t/c/convert.c` to test the conversion functions.
        - Updated documentation in `ProtobufPlan.md` and `architecture/testing/01-xs-testing.md` to reflect new test names.
    
    
    ## 0.12	2025-12-17
    
    commit d8cb5dd415c6c129e71cd452f78e29de398a82c9
    Author: C.J. Collier 
    Date:   Wed Dec 17 20:47:38 2025 +0000
    
        feat(perl): Refactor XS code into subdirectories
        
        This commit reorganizes the C code in the `perl/xs/` directory into subdirectories, mirroring the structure of the Python UPB extension. This enhances modularity and maintainability.
        
        - Created subdirectories for each major component: `convert`, `descriptor`, `descriptor_containers`, `descriptor_pool`, `extension_dict`, `map`, `message`, `protobuf`, `repeated`, and `unknown_fields`.
        - Created skeleton `.h` and `.c` files within each subdirectory to house the component-specific logic.
        - Updated top-level component headers (e.g., `perl/xs/descriptor.h`) to include the new sub-headers.
        - Updated top-level component source files (e.g., `perl/xs/descriptor.c`) to include their main header and added stub initialization functions (e.g., `PerlUpb_InitDescriptor`).
        - Moved code from the original `perl/xs/protobuf.c` to new files in `perl/xs/protobuf/` (arena, obj_cache, utils).
        - Moved code from the original `perl/xs/convert.c` to new files in `perl/xs/convert/` (upb_to_sv, sv_to_upb).
        - Updated `perl/Makefile.PL` to use a glob (`xs/*/*.c`) to find the new C source files in the subdirectories.
        - Added `perl/doc/architecture/core/07-xs-file-organization.md` to document the new structure.
        - Updated `perl/doc/ProtobufPlan.md` and other architecture documents to reference the new organization.
        - Corrected self-referential includes in the newly created .c files.
        
        This restructuring provides a solid foundation for further development and makes it easier to port logic from the Python implementation.
    
    
    ## 0.11	2025-12-17
    
    commit cdedcd13ded4511b0464f5d3bdd72ce6d34e73fc
    Author: C.J. Collier 
    Date:   Wed Dec 17 19:57:52 2025 +0000
    
        feat(perl): Implement C-first testing and core XS infrastructure
        
        This commit introduces a significant refactoring of the Perl XS extension, adopting a C-first development approach to ensure a robust foundation.
        
        Key changes include:
        
        -   **C-Level Testing Framework:** Established a C-level testing system in `t/c/` with a dedicated Makefile, using an embedded Perl interpreter. Initial tests cover the object cache (`01-cache.c`), arena wrapper (`02-arena.c`), and utility functions (`03-utils.c`).
        -   **Core XS Infrastructure:**
            -   Implemented a global object cache (`xs/protobuf.c`) to manage Perl wrappers for UPB objects, using weak references.
            -   Created an `upb_Arena` wrapper (`xs/protobuf.c`).
            -   Consolidated common XS helper functions into `xs/protobuf.h` and `xs/protobuf.c`.
        -   **Makefile.PL Enhancements:** Updated to support building and linking C tests, incorporating flags from `ExtUtils::Embed`, and handling both `.c` and `.cc` source files.
        -   **XS File Reorganization:** Restructured XS files to mirror the Python UPB extension's layout (e.g., `message.c`, `descriptor.c`). Removed older, monolithic `.xs` files.
        -   **Typemap Expansion:** Added extensive typemap entries in `perl/typemap` to handle conversions between Perl objects and various `const upb_*Def*` pointers.
        -   **Descriptor Tests:** Added a new test suite `t/02-descriptor.t` to validate descriptor loading and accessor methods.
        -   **Documentation:** Updated development plans and guidelines (`ProtobufPlan.md`, `xs_learnings.md`, etc.) to reflect the C-first strategy, new testing methods, and lessons learned.
        -   **Build Cleanup:** Removed `ppport.h` from `.gitignore` as it's no longer used, due to `-DPERL_NO_PPPORT` being set in `Makefile.PL`.
        
        This C-first approach allows for more isolated and reliable testing of the core logic interacting with the UPB library before higher-level Perl APIs are built upon it.
    
    
    ## 0.10	2025-12-17
    
    commit 1ef20ade24603573905cb0376670945f1ab5d829
    Author: C.J. Collier 
    Date:   Wed Dec 17 07:08:29 2025 +0000
    
        feat(perl): Implement C-level tests and core XS utils
        
        This commit introduces a C-level testing framework for the XS layer and implements key components:
        
        1.  **C-Level Tests (`t/c/`)**:
            *   Added `t/c/Makefile` to build standalone C tests.
            *   Created `t/c/upb-perl-test.h` with macros for TAP-compliant C tests (`plan`, `ok`, `is`, `is_string`, `diag`).
            *   Implemented `t/c/01-cache.c` to test the object cache.
            *   Implemented `t/c/02-arena.c` to test `Protobuf::Arena` wrappers.
            *   Implemented `t/c/03-utils.c` to test string utility functions.
            *   Corrected include paths and diagnostic messages in C tests.
        
        2.  **XS Object Cache (`xs/protobuf.c`)**:
            *   Switched to using stringified pointers (`%p`) as hash keys for stability.
            *   Fixed a critical double-free bug in `PerlUpb_ObjCache_Delete` by removing an extra `SvREFCNT_dec` on the lookup key.
        
        3.  **XS Arena Wrapper (`xs/protobuf.c`)**:
            *   Corrected `PerlUpb_Arena_New` to use `newSVrv` and `PTR2IV` for opaque object wrapping.
            *   Corrected `PerlUpb_Arena_Get` to safely unwrap the arena pointer.
        
        4.  **Makefile.PL (`perl/Makefile.PL`)**:
            *   Added `-Ixs` to `INC` to allow C tests to find `t/c/upb-perl-test.h` and `xs/protobuf.h`.
            *   Added `LIBS` to link `libprotobuf_common.a` into the main `Protobuf.so`.
            *   Added C test targets `01-cache`, `02-arena`, `03-utils` to the test config in `MY::postamble`.
        
        5.  **Protobuf.pm (`perl/lib/Protobuf.pm`)**:
            *   Added `use XSLoader;` to load the compiled XS code.
        
        6.  **New files `xs/util.h`**:
            *   Added initial type conversion function.
        
        These changes establish a foundation for testing the C-level interface with UPB and fix crucial bugs in the object cache implementation.
    
    
    ## 0.09	2025-12-17
    
    commit 07d61652b032b32790ca2d3848243f9d75ea98f4
    Author: C.J. Collier 
    Date:   Wed Dec 17 04:53:34 2025 +0000
    
        feat(perl): Build system and C cache test for Perl XS
        
        This commit introduces the foundational pieces for the Perl XS implementation, focusing on the build system and a C-level test for the object cache.
        
        -   **Makefile.PL:**
            -   Refactored C test compilation rules in `MY::postamble` to use a hash (`$c_test_config`) for better organization and test-specific flags.
            -   Integrated `ExtUtils::Embed` to provide necessary compiler and linker flags for embedding the Perl interpreter, specifically for the `t/c/01-cache.c` test.
            -   Correctly constructs the path to the versioned Perl library (`libperl.so.X.Y.Z`) using `$Config{archlib}` and `$Config{libperl}` to ensure portability.
            -   Removed `VERSION_FROM` and `ABSTRACT_FROM` to avoid dependency on `.pm` files for now.
        
        -   **C Cache Test (t/c/01-cache.c):**
            -   Added a C test to exercise the object cache functions implemented in `xs/protobuf.c`.
            -   Includes tests for adding, getting, deleting, and weak reference behavior.
        
        -   **XS Cache Implementation (xs/protobuf.c, xs/protobuf.h):**
            -   Implemented `PerlUpb_ObjCache_Init`, `PerlUpb_ObjCache_Add`, `PerlUpb_ObjCache_Get`, `PerlUpb_ObjCache_Delete`, and `PerlUpb_ObjCache_Destroy`.
            -   Uses a Perl hash (`HV*`) for the cache.
            -   Keys are string representations of the C pointers, created using `snprintf` with `"%llx"`.
            -   Values are weak references (`sv_rvweaken`) to the Perl objects (`SV*`).
            -   `PerlUpb_ObjCache_Get` now correctly returns an incremented reference to the original SV, not a copy.
            -   `PerlUpb_ObjCache_Destroy` now clears the hash before decrementing its refcount.
        
        -   **t/c/upb-perl-test.h:**
            -   Updated `is_sv` to perform direct pointer comparison (`got == expected`).
        
        -   **Minor:** Added `util.h` (currently empty), updated `typemap`.
        
        These changes establish a working C-level test environment for the XS components.
    
    
    ## 0.08	2025-12-17
    
    commit d131fd22ea3ed8158acb9b0b1fe6efd856dc380e
    Author: C.J. Collier 
    Date:   Wed Dec 17 02:57:48 2025 +0000
    
        feat(perl): Update docs and core XS files
        
        - Explicitly add TDD cycle to ProtobufPlan.md.
        - Clarify mirroring of Python implementation in upb-interfacing.md for both C and Perl layers.
        - Branch and adapt python/protobuf.h and python/protobuf.c to perl/xs/protobuf.h and perl/xs/protobuf.c, including the object cache implementation. Removed old cache.* files.
        - Create initial C test for the object cache in t/c/01-cache.c.
    
    
    ## 0.07	2025-12-17
    
    commit 56fd6862732c423736a2f9a9fb1a2816fc59e9b0
    Author: C.J. Collier 
    Date:   Wed Dec 17 01:09:18 2025 +0000
    
        feat(perl): Align Perl UPB architecture docs with Python
        
        Updates the Perl Protobuf architecture documents to more closely align with the design and implementation strategies used in the Python UPB extension.
        
        Key changes:
        
        -   **Object Caching:** Mandates a global, per-interpreter cache using weak references for all UPB-derived objects, mirroring Python's `PyUpb_ObjCache`.
        -   **Descriptor Containers:** Introduces a new document outlining the plan to use generic XS container types (Sequence, ByNameMap, ByNumberMap) with vtables to handle collections of descriptors, similar to Python's `descriptor_containers.c`.
        -   **Testing:** Adds a note to the testing strategy to port relevant test cases from the Python implementation to ensure feature parity.
    
    
    ## 0.06	2025-12-17
    
    commit 6009ce6ab64eccce5c48729128e5adf3ef98e9ae
    Author: C.J. Collier 
    Date:   Wed Dec 17 00:28:20 2025 +0000
    
        feat(perl): Implement object caching and fix build
        
        This commit introduces several key improvements to the Perl XS build system and core functionality:
        
        1.  **Object Caching:**
            *   Introduces `xs/protobuf.c` and `xs/protobuf.h` to implement a caching mechanism (`protobuf_c_to_perl_obj`) for wrapping UPB C pointers into Perl objects. This uses a hash and weak references to ensure object identity and prevent memory leaks.
            *   Updates the `typemap` to use `protobuf_c_to_perl_obj` for `upb_MessageDef *` output, ensuring descriptor objects are cached.
            *   Corrected `sv_weaken` to the correct `sv_rvweaken` function.
        
        2.  **Makefile.PL Enhancements:**
            *   Switched to using the Bazel-generated UPB descriptor sources from `bazel-bin/src/google/protobuf/_virtual_imports/descriptor_proto/google/protobuf/`.
            *   Updated `INC` paths to correctly locate the generated headers.
            *   Refactored `MY::dynamic_lib` to ensure the static library `libprotobuf_common.a` is correctly linked into each generated `.so` module, resolving undefined symbol errors.
            *   Overrode `MY::test` to use `prove -b -j$(nproc) t/*.t xt/*.t` for running tests.
            *   Cleaned up `LIBS` and `LDDLFLAGS` usage.
        
        3.  **Documentation:**
            *   Updated `ProtobufPlan.md` to reflect the current status and design decisions.
            *   Reorganized architecture documents into subdirectories.
            *   Added `object-caching.md` and `c-perl-interface.md`.
            *   Updated `llm-guidance.md` with notes on `upb/upb.h` and `sv_rvweaken`.
        
        4.  **Testing:**
            *   Fixed `xt/03-moo_immutable.t` to skip tests if no Moo modules are found.
        
        This resolves the build issues and makes the core test suite pass.
    
    
    ## 0.05	2025-12-16
    
    commit 177d2f3b2608b9d9c415994e076a77d8560423b8
    Author: C.J. Collier 
    Date:   Tue Dec 16 19:51:36 2025 +0000
    
        Refactor: Rename namespace to Protobuf, build system and doc updates
        
        This commit refactors the primary namespace from `ProtoBuf` to `Protobuf`
        to align with the style guide. This involves renaming files, directories,
        and updating package names within all Perl and XS files.
        
        **Namespace Changes:**
        
        *   Renamed `perl/lib/ProtoBuf` to `perl/lib/Protobuf`.
        *   Moved and updated `ProtoBuf.pm` to `Protobuf.pm`.
        *   Moved and updated `ProtoBuf::Descriptor` to `Protobuf::Descriptor` (.pm & .xs).
        *   Removed other `ProtoBuf::*` stubs (Arena, DescriptorPool, Message).
        *   Updated `MODULE` and `PACKAGE` in `Descriptor.xs`.
        *   Updated `NAME`, `*_FROM` in `perl/Makefile.PL`.
        *   Replaced `ProtoBuf` with `Protobuf` throughout `perl/typemap`.
        *   Updated namespaces in test files `t/01-load-protobuf-descriptor.t` and `t/02-descriptor.t`.
        *   Updated namespaces in all documentation files under `perl/doc/`.
        *   Updated paths in `perl/.gitignore`.
        
        **Build System Enhancements (Makefile.PL):**
        
        *   Included `xs/*.c` files in the common object files list.
        *   Added `-I.` to the `INC` paths.
        *   Switched from `MYEXTLIB` to `LIBS => ['-L$(CURDIR) -lprotobuf_common']` for linking.
        *   Removed custom keys passed to `WriteMakefile` for postamble.
        *   `MY::postamble` now sources variables directly from the main script scope.
        *   Added `all :: ${common_lib}` dependency in `MY::postamble`.
        *   Added `t/c/load_test.c` compilation rule in `MY::postamble`.
        *   Updated `clean` target to include `blib`.
        *   Added more modules to `TEST_REQUIRES`.
        *   Removed the explicit `PM` and `XS` keys from `WriteMakefile`, relying on `XSMULTI => 1`.
        
        **New Files:**
        
        *   `perl/lib/Protobuf.pm`
        *   `perl/lib/Protobuf/Descriptor.pm`
        *   `perl/lib/Protobuf/Descriptor.xs`
        *   `perl/t/01-load-protobuf-descriptor.t`
        *   `perl/t/02-descriptor.t`
        *   `perl/t/c/load_test.c`: Standalone C test for UPB.
        *   `perl/xs/types.c` & `perl/xs/types.h`: For Perl/C type conversions.
        *   `perl/doc/architecture/upb-interfacing.md`
        *   `perl/xt/03-moo_immutable.t`: Test for Moo immutability.
        
        **Deletions:**
        
        *   Old test files: `t/00_load.t`, `t/01_basic.t`, `t/02_serialize.t`, `t/03_message.t`, `t/04_descriptor_pool.t`, `t/05_arena.t`, `t/05_message.t`.
        *   Removed `lib/ProtoBuf.xs` as it's not needed with `XSMULTI`.
        
        **Other:**
        
        *   Updated `test_descriptor.bin` (binary change).
        *   Significant content updates to markdown documentation files in `perl/doc/architecture` and `perl/doc/internal` reflecting the new architecture and learnings.
    
    
    ## 0.04	2025-12-14
    
    commit 92de5d482c8deb9af228f4b5ce31715d3664d6ee
    Author: C.J. Collier 
    Date:   Sun Dec 14 21:28:19 2025 +0000
    
        feat(perl): Implement Message object creation and fix lifecycles
        
        This commit introduces the basic structure for `ProtoBuf::Message` object
        creation, linking it with `ProtoBuf::Descriptor` and `ProtoBuf::DescriptorPool`,
        and crucially resolves a SEGV by fixing object lifecycle management.
        
        Key Changes:
        
        1.  **`ProtoBuf::Descriptor`:** Added `_pool` attribute to hold a strong
            reference to the parent `ProtoBuf::DescriptorPool`. This is essential to
            prevent the pool and its C `upb_DefPool` from being garbage collected
            while a descriptor is still in use.
        
        2.  **`ProtoBuf::DescriptorPool`:**
            *   `find_message_by_name`: Now passes the `$self` (the pool object) to the
                `ProtoBuf::Descriptor` constructor to establish the lifecycle link.
            *   XSUB `pb_dp_find_message_by_name`: Updated to accept the pool `SV*` and
                store it in the descriptor's `_pool` attribute.
            *   XSUB `_load_serialized_descriptor_set`: Renamed to avoid clashing with the
                Perl method name. The Perl wrapper now correctly calls this internal XSUB.
            *   `DEMOLISH`: Made safer by checking for attribute existence.
        
        3.  **`ProtoBuf::Message`:**
            *   Implemented using Moo with lazy builders for `_upb_arena` and
                `_upb_message`.
            *   `_descriptor` is a required argument to `new()`.
            *   XS functions added for creating the arena (`pb_msg_create_arena`) and
                the `upb_Message` (`pb_msg_create_upb_message`).
            *   `pb_msg_create_upb_message` now extracts the `upb_MessageDef*` from the
                descriptor and uses `upb_MessageDef_MiniTable()` to get the minitable
                for `upb_Message_New()`.
            *   `DEMOLISH`: Added to free the message's arena.
        
        4.  **`Makefile.PL`:**
            *   Added `-g` to `CCFLAGS` for debugging symbols.
            *   Added Perl CORE include path to `MY::postamble`'s `base_flags`.
        
        5.  **Tests:**
            *   `t/04_descriptor_pool.t`: Updated to check the structure of the
                returned `ProtoBuf::Descriptor`.
            *   `t/05_message.t`: Now uses a descriptor obtained from a real pool to
                test `ProtoBuf::Message->new()`.
        
        6.  **Documentation:**
            *   Updated `ProtobufPlan.md` to reflect progress.
            *   Updated several files in `doc/architecture/` to match the current
                implementation details, especially regarding arena management and object
                lifecycles.
            *   Added `doc/internal/development_cycle.md` and `doc/internal/xs_learnings.md`.
        
        With these changes, the SEGV is resolved, and message objects can be successfully
        created from descriptors.
    
    
    ## 0.03	2025-12-14
    
    commit 6537ad23e93680c2385e1b571d84ed8dbe2f68e8
    Author: C.J. Collier 
    Date:   Sun Dec 14 20:23:41 2025 +0000
    
        Refactor(perl): Object-Oriented DescriptorPool with Moo
        
        This commit refactors the `ProtoBuf::DescriptorPool` to be fully object-oriented using Moo, and resolves several issues related to XS, typemaps, and test data.
        
        Key Changes:
        
        1.  **Moo Object:** `ProtoBuf::DescriptorPool.pm` now uses `Moo` to define the class. The `upb_DefPool` pointer is stored as a lazy attribute `_upb_defpool`.
        2.  **XS Lifecycle:** `DescriptorPool.xs` now has `pb_dp_create_pool` called by the Moo builder and `pb_dp_free_pool` called from `DEMOLISH` to manage the `upb_DefPool` lifecycle per object.
        3.  **Typemap:** The `perl/typemap` file has been significantly updated to handle the conversion between the `ProtoBuf::DescriptorPool` Perl object and the `upb_DefPool *` C pointer. This includes:
            *   Mapping `upb_DefPool *` to `T_PTR`.
            *   An `INPUT` section for `ProtoBuf::DescriptorPool` to extract the pointer from the object's hash, triggering the lazy builder if needed via `call_method`.
            *   An `OUTPUT` section for `upb_DefPool *` to convert the pointer back to a Perl integer, used by the builder.
        4.  **Method Renaming:** `add_file_descriptor_set_binary` is now `load_serialized_descriptor_set`.
        5.  **Test Data:**
            *   Added `perl/t/data/test.proto` with a sample message and enum.
            *   Generated `perl/t/data/test_descriptor.bin` using `protoc`.
            *   Removed `t/data/` from `.gitignore` to ensure test data is versioned.
        6.  **Test Update:** `t/04_descriptor_pool.t` is updated to use the new OO interface, load the generated descriptor set, and check for message definitions.
        7.  **Build Fixes:**
            *   Corrected `#include` paths in `DescriptorPool.xs` to be relative to the `upb/` directory (e.g., `upb/wire/decode.h`).
            *   Added `-I../upb` to `CCFLAGS` in `Makefile.PL`.
            *   Reordered `INC` paths in `Makefile.PL` to prioritize local headers.
        
        **Note:** While tests now pass in some environments, a SEGV issue persists in `make test` runs, indicating a potential memory or lifecycle issue within the XS layer that needs further investigation.
    
    
    ## 0.02	2025-12-14
    
    commit 6c9a6f1a5f774dae176beff02219f504ea3a6e07
    Author: C.J. Collier 
    Date:   Sun Dec 14 20:13:09 2025 +0000
    
        Fix(perl): Correct UPB build integration and generated file handling
        
        This commit resolves several issues to achieve a successful build of the Perl extension:
        
        1.  **Use Bazel Generated Files:** Switched from compiling UPB's stage0 descriptor.upb.c to using the Bazel-generated `descriptor.upb.c` and `descriptor.upb_minitable.c` located in `bazel-bin/src/google/protobuf/_virtual_imports/descriptor_proto/google/protobuf/`.
        2.  **Updated Include Paths:** Added the `bazel-bin` path to `INC` in `WriteMakefile` and to `base_flags` in `MY::postamble` to ensure the generated headers are found during both XS and static library compilation.
        3.  **Removed Stage0:** Removed references to `UPB_STAGE0_DIR` and no longer include headers or source files from `upb/reflection/stage0/`.
        4.  **-fPIC:** Explicitly added `-fPIC` to `CCFLAGS` in `WriteMakefile` and ensured `$(CCFLAGS)` is used in the custom compilation rules in `MY::postamble`. This guarantees all object files in the static library are compiled with position-independent code, resolving linker errors when creating the shared objects for the XS modules.
        5.  **Refined UPB Sources:** Used `File::Find` to recursively find UPB C sources, excluding `/conformance/` and `/reflection/stage0/` to avoid conflicts and unnecessary compilations.
        6.  **Arena Constructor:** Modified `ProtoBuf::Arena::pb_arena_new` XSUB to accept the class name argument passed from Perl, making it a proper constructor.
        7.  **.gitignore:** Added patterns to `perl/.gitignore` to ignore generated C files from XS (`lib/*.c`, `lib/ProtoBuf/*.c`), the copied `src_google_protobuf_descriptor.pb.cc`, and the `t/data` directory.
        8.  **Build Documentation:** Updated `perl/doc/architecture/upb-build-integration.md` to reflect the new build process, including the Bazel prerequisite, include paths, `-fPIC` usage, and `File::Find`.
        
        Build Steps:
        1.  `bazel build //src/google/protobuf:descriptor_upb_proto` (from repo root)
        2.  `cd perl`
        3.  `perl Makefile.PL`
        4.  `make`
        5.  `make test` (Currently has expected failures due to missing test data implementation).
    
    
    ## 0.01	2025-12-14
    
    commit 3e237e8a26442558c94075766e0d4456daaeb71d
    Author: C.J. Collier 
    Date:   Sun Dec 14 19:34:28 2025 +0000
    
        feat(perl): Initialize Perl extension scaffold and build system
        
        This commit introduces the `perl/` directory, laying the groundwork for the Perl Protocol Buffers extension. It includes the essential build files, linters, formatter configurations, and a vendored Devel::PPPort for XS portability.
        
        Key components added:
        
        *   **`Makefile.PL`**: The core `ExtUtils::MakeMaker` build script. It's configured to:
            *   Build a static library (`libprotobuf_common.a`) from UPB, UTF8_Range, and generated protobuf C/C++ sources.
            *   Utilize `XSMULTI => 1` to create separate shared objects for `ProtoBuf`, `ProtoBuf::Arena`, and `ProtoBuf::DescriptorPool`.
            *   Link each XS module against the common static library.
            *   Define custom compilation rules in `MY::postamble` to handle C vs. C++ flags and build the static library.
            *   Set up include paths for the project root, UPB, and other dependencies.
        
        *   **XS Stubs (`.xs` files)**:
            *   `lib/ProtoBuf.xs`: Placeholder for the main module's XS functions.
            *   `lib/ProtoBuf/Arena.xs`: XS interface for `upb_Arena` management.
            *   `lib/ProtoBuf/DescriptorPool.xs`: XS interface for `upb_DefPool` management.
        
        *   **Perl Module Stubs (`.pm` files)**:
            *   `lib/ProtoBuf.pm`: Main module, loads XS.
            *   `lib/ProtoBuf/Arena.pm`: Perl class for Arenas.
            *   `lib/ProtoBuf/DescriptorPool.pm`: Perl class for Descriptor Pools.
            *   `lib/ProtoBuf/Message.pm`: Base class for messages (TBD).
        
        *   **Configuration Files**:
            *   `.gitignore`: Ignores build artifacts, editor files, etc.
            *   `.perlcriticrc`: Configures Perl::Critic for static analysis.
            *   `.perltidyrc`: Configures perltidy for code formatting.
        
        *   **`Devel::PPPort`**: Vendored version 3.72 to generate `ppport.h` for XS compatibility across different Perl versions.
        
        *   **`typemap`**: Custom typemap for XS argument/result conversion.
        
        *   **Documentation (`doc/`)**: Initial architecture and plan documents.
        
        This provides a solid foundation for developing the UPB-based Perl extension.
    
    
    
  • Installing a desktop environment on the HP Omen

    `dmidecode | grep -A8 ‘^System Information’`

    tells me that the Manufacturer is HP and Product Name is OMEN Transcend Gaming Laptop 14-fb0xxx

    I’m provisioning a new piece of hardware for my eng consultant and it’s proving more difficult than I expected. I must admit guilt for some of this difficulty. Instead of installing using the debian installer on my keychain, I dd’d the pv block device of the 16 inch 2023 version onto the partition set aside from it. I then rebooted into rescue mode and cleaned up the grub config, corrected the EFI boot partition’s path in /etc/fstab, ran the grub installer from the rescue menu, and rebooted.

    On the initial boot of the system, X or Wayland or whatever is supposed to be talking to this vast array of GPU hardware in this device, it’s unable to do more than create a black screen on vt1. It’s easy enough to switch to vt2 and get a shell on the installed system. So I’m doing that and investigating what’s changed in Trixie. It seems like it’s pretty significant. Did they just throw out Keith Packard’s and Behdad Esfahbod’s work on font rendering? I don’t understand what’s happening in this effort to abstract to a simpler interface. I’ll probably end up reading more about it.

    In an effort to have Debian re-configure the system for Desktop use, I have uninstalled as many packages as I could find that were in the display and human interface category, or were firmware/drivers for devices not present in this Laptop’s SoC. Some commands I used to clear these packages and re-install connamon follow:

    ```
    dpkg -S /etc/X11
    dpkg -S /usr/lib/firmware
    apt-get purge $(dpkg -l | grep -i \
      -e gnome -e gtk -e x11-common -e xfonts- -e libvdpau -e dbus-user-session -e gpg-agent \
      -e bluez -e colord -e cups -e fonts -e drm -e xf86 -e mesa -e nouveau -e cinnamon \
      -e avahi -e gdk -e pixel -e desktop -e libreoffice -e x11 -e wayland -e xorg \
      -e firmware-nvidia-graphics -e firmware-amd-graphics -e firmware-mediatek -e firmware-realtek \
      | awk '{print $2}')
    apt-get autoremove
    apt-get purge $(dpkg -l | grep '^r' | awk '{print $2}')
    tasksel install cinnamon-desktop
    ```

    And then I rebooted. When it came back up, I was greeted with a login prompt, and Trixie looks to be fully functional on this device, including the attached wifi radio, tethering to my android, and the thunderbolt-attached Marvell SFP+ enclosure.

    I’m also installing libvirt and fetched the DVD iso material for Debian, Ubuntu and Rocky in case we have a need of building VMs during the development process. These are the platforms that I target at work with gcp Dataproc, so I’m pretty good at performing maintenance operation on them at this point.

  • Signed NVIDIA drivers on Google Cloud Dataproc 2.2

    Hello folks,

    I’ve been working this year on better integrating NVIDIA hardware with the Google Cloud Dataproc product (Hadoop on Google Cloud) running the default cluster node image. We have an open bug[1] in the initialization-actions repo regarding creation failures upon enabling secure boot. This is because with secure boot, kernel driver code has its signature verified before insmod places the symbols into kernel memory. The verification process involves reading trust root certificates from EFI variables, and validating that the signatures on the kernel driver either a) were made directly by one of the certificates in the boot sector or b) were made by certificates which chain up to one of them.

    This means that Dataproc disk images must have a certificate installed into them. My work on the internals will likely start producing images which have certificates from Google in them. In the meantime, however, our users are left without a mechanism to have both secure boot enabled and install out-of-tree kernel modules such as the NVIDIA GPU drivers. To that end, I’ve got PR #83[2] open with the GoogleCloudDataproc/custom-images github repository. This PR introduces a new argument to the custom image creation script, `–trusted-cert`, the argument of which is the path to a DER-encoded certificate to be included in the certificate database in the EFI variables of the disk’s boot sector.

    I’ve written up the instructions on creating a custom image with a trusted certificate here:

    https://github.com/cjac/custom-images/blob/secure-boot-custom-image/examples/secure-boot/README.md

    Here is a set of commands that can be used to create a Dataproc custom image with certificate installed to the EFI’s db variable. You can run these commands from the root directory of a checkout such as this:

    
    
    git clone https://github.com/cjac/custom-images.git --branch secure-boot-custom-image --single-branch
    pushd custom-images
    PROJECT_ID=your-project-here
    PROJECT_NUMBER=your-project-nnnn-here
    my_bucket=your-bucket-here
    custom_image_zone=your-zone-here
    
    gcloud projects add-iam-policy-binding ${PROJECT_ID} \
            --member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com \
            --role=roles/secretmanager.secretAccessor
    gcloud config set project ${PROJECT_ID}
    
    gcloud auth login
    
    eval $(bash examples/secure-boot/create-key-pair.sh)
    metadata="public_secret_name=${public_secret_name}"
    metadata="${metadata},private_secret_name=${private_secret_name}"
    metadata="${metadata},secret_project=${secret_project}"
    metadata="${metadata},secret_version=${secret_version}"
    
    #dataproc_version=2.1-debian11
    dataproc_version=2.2-debian12
    #customization_script=examples/secure-boot/install-nvidia-driver-debian11.sh
    customization_script=examples/secure-boot/install-nvidia-driver-debian12.sh
    #image_name="nvidia-open-kernel-bullseye-$(date +%F)"
    image_name="nvidia-open-kernel-bookworm-$(date +%F)"
    disk_size_gb="50"
    
    python generate_custom_image.py \
        --image-name ${image_name} \
        --dataproc-version ${dataproc_version} \
        --trusted-cert "tls/db.der" \
        --customization-script ${customization_script} \
        --metadata "${metadata}" \
        --zone "${custom_image_zone}" \
        --disk-size "${disk_size_gb}" \
        --no-smoke-test \
        --gcs-bucket "${my_bucket}"
    popd
    

    I’d love to hear your feedback!

    [1] https://github.com/GoogleCloudDataproc/initialization-actions/issues/1058
    [2] https://github.com/GoogleCloudDataproc/custom-images/pull/83

  • IPv6 with CenturyLink Fiber

    In case you want to know how to configure IPv6 using CenturyLink’s 6rd tunneling service.

    There are four files to update with my script:

    There are a couple of environment variables in /etc/default/centurylink-6rd that you will want to set. Mine looks like this:

    LAN_IFACE="ens18,ens21,ens22"
    HEADER_FILE=/etc/radvd.conf.header
    

    The script will configure radvd to advertise v6 routes to a /64 of clients on each of the interfaces delimited by a comma in LAN_IFACE. Current interface limit is 9. I can patch something to go up to 0xff, but I don’t want to at this time.

    If you have some static configuration that you want to preserve, place them into the file pointed to by ${HEADER_FILE} and it will be prepended to the generated /etc/radvd.conf file. The up script will remove the file and re-create it every time your ppp link comes up, so keep that in mind and don’t manually modify the file and expect it to perist. You’ve been warned :-)

    So here’s the script. It’s also linked above if you want to curl it.

    #!/bin/bash
    #
    # Copyright 2023 Collier Technologies LLC
    # https://wp.c9h.org/cj/?p=1844
    #
    
    # # These variables are for the use of the scripts run by run-parts
    # PPP_IFACE="$1"
    # PPP_TTY="$2"
    # PPP_SPEED="$3"
    # PPP_LOCAL="$4"
    # PPP_REMOTE="$5"
    # PPP_IPPARAM="$6"
    
    ${PPP_IFACE:="ppp0"}
    if [[ -z ${PPP_LOCAL} ]]; then
        PPP_LOCAL=$(curl -s https://icanhazip.com/)
    fi
    
    6rd_prefix="2602::/24"
    
    #printf "%x%x:%x%x\n" $(echo $PPP_LOCAL | tr . ' ')
    
    # This configuration option came from CenturyLink:
    # https://www.centurylink.com/home/help/internet/modems-and-routers/advanced-setup/enable-ipv6.html
    border_router=205.171.2.64
    
    TUNIFACE=6rdif
    
    first_ipv6_network=$(printf "2602:%02x:%02x%02x:%02x00::" $(echo ${PPP_LOCAL} | tr . ' '))
    
    ip tunnel del ${TUNIFACE} 2>/dev/null
    ip -l 5 -6 addr flush scope global dev ${IFACE}
    
    ip tunnel add ${TUNIFACE} mode sit local ${PPP_LOCAL} remote ${border_router}
    ip tunnel 6rd dev ${TUNIFACE} 6rd-prefix "${first_ipv6_network}0/64" 6rd-relay_prefix ${border_router}/32
    ip link set up dev ${TUNIFACE}
    ip -6 route add default dev ${TUNIFACE}
    
    ip addr add ${first_ipv6_network}1/64 dev ${TUNIFACE}
    
    rm /etc/radvd.conf
    i=1
    DEFAULT_FILE="/etc/default/centurylink-6rd"
    if [[ -f ${DEFAULT_FILE} ]]; then
        source ${DEFAULT_FILE}
        if [[ -f ${HEADER_FILE} ]]; then
    	cp ${HEADER_FILE} /etc/radvd.conf
        fi
    else
        LAN_IFACE="setThis"
    fi
       
    for IFACE in $( echo ${LAN_IFACE} | tr , ' ' ) ; do
    
        ipv6_network=$(printf "2602:%02x:%02x%02x:%02x0${i}::" $(echo ${PPP_LOCAL} | tr . ' '))
    
        ip addr add ${ipv6_network}1/64 dev ${TUNIFACE}
        ip -6 route replace "${ipv6_network}/64" dev ${IFACE} metric 1
    
        echo "
    interface ${IFACE} {
       AdvSendAdvert on;
       MinRtrAdvInterval 3;
       MaxRtrAdvInterval 10;
       AdvLinkMTU 1280;
       prefix ${ipv6_network}/64 {
         AdvOnLink on;
         AdvAutonomous on;
         AdvRouterAddr on;
         AdvValidLifetime 86400;
         AdvPreferredLifetime 86400;
       };
    };
    " >> /etc/radvd.conf
    
        let "i=i+1"
    done
    
    systemctl restart radvd
    
  • The woes of 520-byte sectors

    A couple years ago, I bought a 12G/s SAS disk to see if I could get it to work with the RAID controller with external SFF-8088 ports which came with the system I got while I was working at The Linux Foundation. I got an enclosure to go with it because I was enthusiastic and optimistic about my ability to get things all set up. My plan was to take the 1T disks I had in the storage server I had been using before, but which had since failed and to put them into this new enclosure. I got a couple of SFF-8088 cables, and the enclosure had some SFF-8088 to 7-pin SATA break-outs come with it. I bought an additional dual SFF-8088 to SFF-8087 adapter and a couple of SFF-8087 to 4x SFF-8482 cables. I got the 8482s because I imagined that these would be required to take full advantage of the 6TB 12G/s SAS disk mentioned above.

    Unfortunately, when I attached the disks to the controller, none of them worked and I gave up frustrated and disillusioned for a good long time. Last week was spring break, and I took a few days off from work to hang out with my girls. While we weren’t all goofing off together, I was puttering around with a new HBA I got to replace the apparently non-functional HP RAID controller which came with the server.

    However, when I removed the HP RAID controller and put in the LSI 9201-16E HBA I got to replace it with, there was again no SCSI love. The lsscsi command showed nothing. But the lspci command showed the controller, and I started digging through documentation to figure out what might be wrong. I eventually stumbled upon a firmware flashing ISO disk image on the Broadcom site. Broadcom apparently purchased LSI not too long ago and is now responsible for managing documentation and downloads for the legacy devices, of which I am now a proud owner.

    I was able to build a USB disk from this ISO using unetbootin and emacs. I had to modify the syslinux.cfg file to correct the path and case of the filenames. And for some reason, unetbootin replaced the filename of the disk image from which freedos was supposed to boot with something useless. In any case, after corrections, the entry in syslinux.cfg looks like this:

    label ubnentry20
    menu label 9201_16e
    kernel /BOOT/ISOLINUX/MEMDISK
    append initrd=/LSI/IMG/9201_16E.IMG

    Unfortunately, the firmware on the 9201_16E.IMG fat filesystem was old, so I loop mounted it and wrote a more recent version of the firmware, mptsas2.rom and sas2flsh.exe to it. I’ve uploaded it to 9201_16E.IMG in case anyone might find it useful. While I’m at it, I suppose I should put the whole usb boot image up for those who might need it. See lsi-flash-usb.img.bz2. To use this disk image, decompress the .bz2 file and dd it to your USB block device, for instance /dev/sdb in my case:

    $ bunzip2 /tmp/lsi-flash-usb.img.bz2 | sudo dd of=/dev/sdb
    

    My Proliant DL370 G6 server doesn’t have a fancy new UEFI system, so I used this boot disk to get access to the SAS controller in real mode. Once I booted it and selected 9201_16e (the 21st option from the top), I had to rapidly press the up or down arrow and select the EMM386 option to load the driver. For those playing along at home, I placed the more recent LSI controller firmware and BIOS in the \CJ directory, which has the same structure as the \LSI directory from the original disk image. You should be able to

    cd \CJ

    and run

    9201.bat

    Answer the prompts, and afterwards you should have a controller with P20 firmware and BIOS written to it.

    Daunting as this was, it only got me most of the way through the process. All of my SATA disks were working at this point, but the SAS disk was not. After some sleuthing, I discovered that the disk was SCSI formatted to 520 byte sectors. Linux does not accept sector sizes that are not a power of 2, and so i was unable to do anything with the disk using fdisk, kpartx, etc. Research pointed me to the sg_format utility, but I was unable to make that work. Here’s the output of the command:

    $ sudo sg_format --format --size 512 -vv /dev/sg4
    open /dev/sg4 with flags=0x802
        inquiry cdb: 12 00 00 00 24 00 
        SEAGATE   DKS2F-H6R0SS      7FA6   peripheral_type: disk [0x0]
          PROTECT=0
        inquiry cdb: 12 01 00 00 24 00 
        inquiry cdb: 12 01 80 01 00 00 
          Unit serial number: Z4D0M2BF0000W515S4WH
        inquiry cdb: 12 01 83 01 00 00 
          LU name: 5000c50062ba7973
        mode sense (10) cdb: 5a 00 01 00 00 00 00 00 fc 00 
        mode sense (10): pass-through requested 252 bytes (data-in) but got 28 bytes
    Mode Sense (block descriptor) data, prior to changes:
    Mode sense number of blocks maxed out, set longlba
        mode sense (10) cdb: 5a 10 01 00 00 00 00 00 fc 00 
        mode sense (10): pass-through requested 252 bytes (data-in) but got 36 bytes
    Mode Sense (block descriptor) data, prior to changes:
      <<< longlba flag set (64 bit lba) >>>
      Number of blocks=11473076960 [0x2abd942e0]
      Block size=520 [0x208]
        mode select (10) cdb: 55 11 00 00 00 00 00 00 22 00 
        mode select (10) parameter list
    00 00 00 00 01 00 00 10  00 00 00 00 00 00 00 00
    00 00 00 00 00 00 04 00  01 0a 0c 14 ff 00 00 00
    05 00
    mode select (10):
    Descriptor format, current; Sense key: Illegal Request
    Additional sense: Parameter list length error
      Descriptor type: Sense key specific: Field pointer:
            Error in Command: byte 7 bit 7
      Descriptor type: Field replaceable unit code: 0x5
      Descriptor type: Vendor specific [0x80]
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 
     Raw sense data (in hex):
            72 05 1a 00 00 00 00 1c  02 06 00 00 cf 00 07 00
            03 02 00 05 80 0e 00 00  00 00 00 00 00 00 00 00
            00 00 00 00
    MODE SELECT command: Illegal request sense key, apart from Invalid opcode
    
    

    I was about to give up, but for some reason did not. I tried to find firmware and read any documentation about my disk, a Seagate ST6000NM0024. Eventually I found a github repo called ToolBin. In this repo there is a program named SeaChest_Format_121_1183_64 which seems to use a proprietary SCSI format command to tell the drive to format itself using 512-byte sectors. I can’t say for certain yet that it works, but it did not immediately fail as sg_format did. The command I used (and this will vary for you, depending on what sg_scan -i tells you is your scsi generic device) is:

    ./SeaChest_Format_121_1183_64 -d /dev/sg5 --fastFormat 1 --formatUnit 512 --confirm I-understand-this-command-will-erase-all-data-on-the-drive

    Assuming this command results in success after the 12 hour run, I will purchase another 7 of these drives and fill out my disk array!

    Sun Apr 14 13:39:48 PDT 2019
            Format Unit Progress = 3.61%
    

    Thanks to the #linux-raid channel for helping me through this!

    Update:

    Mon Apr 15 08:16:00 PDT 2019
            Format Unit Progress = 99.97%
    Mon Apr 15 08:17:00 PDT 2019
            Format Unit Progress = 100.00%
    
    [70874.677389] sd 3:0:2:0: device_block, handle(0x0012)
    [70876.176199] sd 3:0:2:0: device_unblock and setting to running, handle(0x0012)
    [70876.249541] mpt2sas_cm0: removing handle(0x0012), sas_addr(0x5000c50062ba7971)
    [70876.253344] mpt2sas_cm0: removing : enclosure logical id(0x500062b20059ecc0), slot(1)
    [70886.680412] scsi 3:0:3:0: Direct-Access     SEAGATE  DKS2F-H6R0SS     7FA6 PQ: 0 ANSI: 5
    [70886.684166] scsi 3:0:3:0: SSP: handle(0x0012), sas_addr(0x5000c50062ba7971), phy(2), device_name(0x5000c50062ba7970)
    [70886.688833] scsi 3:0:3:0: SSP: enclosure_logical_id(0x500062b20059ecc0), slot(1)
    [70886.750049] sd 3:0:3:0: Attached scsi generic sg5 type 0
    [70886.750143] sd 3:0:3:0: [sdd] Spinning up disk...
    [70887.765498] .
    [70888.789522] .
    [70889.813591] .
    [70890.837718] .
    [70891.861715] .
    [70892.885876] .
    [70893.909889] .
    [70894.933912] .
    [70895.957989] .
    [70896.982028] .
    [70898.006133] .
    [70899.030215] .
    [70900.054269] .
    [70901.078340] .
    [70902.102359] .
    [70903.478491] .
    [70904.502557] .
    [70906.823608] ready
    [70906.826165] sd 3:0:3:0: [sdd] 11721045168 512-byte logical blocks: (6.00 TB/5.46 TiB)
    [70906.829779] sd 3:0:3:0: [sdd] 4096-byte physical blocks
    [70906.834708] sd 3:0:3:0: [sdd] Write Protect is off
    [70906.837364] sd 3:0:3:0: [sdd] Mode Sense: 13 00 10 08
    [70906.838142] sd 3:0:3:0: [sdd] Write cache: disabled, read cache: enabled, supports DPO and FUA
    [70906.867106] sd 3:0:3:0: [sdd] Attached SCSI disk
    
    $ sudo ./SeaChest_Info_141_1183_64  -d /dev/sg5 -i
    ==========================================================================================
     SeaChest_Info - Seagate drive utilities - NVMe Enabled
     Copyright (c) 2014-2018 Seagate Technology LLC and/or its Affiliates, All Rights Reserved
     SeaChest_Info Version: 1.4.1-1_18_3 X86_64
     Build Date: Oct 18 2018
     Today: Mon Apr 15 14:52:33 2019
    ==========================================================================================
    
    /dev/sg5 - DKS2F-H6R0SS - Z4D0M2BF0000W515S4WH - SCSI
            Vendor ID: SEAGATE 
            Model Number: DKS2F-H6R0SS    
            Serial Number: Z4D0M2BF0000W515S4WH
            Firmware Revision: 7FA6
            World Wide Name: 5000C50062BA7973
            Copyright: Copyright (c) 2014 Seagate All rights reserved 
            Drive Capacity (TB/TiB): 6.00/5.46
            Temperature Data:
                    Current Temperature (C): 45
                    Highest Temperature (C): Not Reported
                    Lowest Temperature (C): Not Reported
            Power On Time:  21 days 11 hours 8 minutes 
            Power On Hours: 515.13
            MaxLBA: 11721045167
            Native MaxLBA: Not Reported
            Logical Sector Size (B): 512
            Physical Sector Size (B): 4096
            Sector Alignment: 0
            Rotation Rate (RPM): 7200
            Form Factor (inch): 3.5
            Last DST information:
                    DST has never been run
            Long Drive Self Test Time:  10 hours 2 minutes 
            Interface speed:
                    Port 0 (Current Port)
                            Max Speed (GB/s): 12.0
                            Negotiated Speed (Gb/s): 6.0
                    Port 1
                            Max Speed (GB/s): 12.0
                            Negotiated Speed (Gb/s): Not Reported
            Annualized Workload Rate (TB/yr): 0.00
            Total Bytes Read (MB): 6.39
            Total Bytes Written (MB): 14.99
            Encryption Support: Not Supported
            Cache Size (MiB): Not Reported
            Read Look-Ahead: Not Supported
            Write Cache: Disabled
            SMART Status: Good
            ATA Security Information: Not Supported
            Firmware Download Support: Full, Segmented, Deferred
            Specifications Supported:
                    SPC-3
                    SAM-5
                    SAS-3
                    SPL-3
                    SPC-4
                    SBC-3
            Features Supported:
                    Application Client Logging
                    Self Test
                    Automatic Write Reassignment
                    Automatic Read Reassignment
                    EPC
                    Informational Exceptions [Mode 0]
                    Translate Address
                    Format Unit
                    Sanitize
    
    
  • Some work on a VyOS image with Let’s Encrypt certs

    I put some packages together this weekend. It’s been a while since I’ve debuilt anything officially.

    The plan is to build a binding to the libgnutls.so.30 API. The certtool CSR (REQ) generation interface does not allow me to create a CRL with “not critical” attributes set on purposes. Maybe if I do it a bit closer to the metal it will be easier…

  • LLC-Technologies-Collier/Demo-SCCC-Byte-AngularJS

    Hello dear readers and attendees,

    This is the post that I will be/ will have been referencing during my presentation to the Seattle Central Community College’s Byte club on Thursday, December 10th at 1500-1630.

    I will begin with a bit of an autobio and find out what kind of students we have in attendance. Please feel free to comment if you’d like to keep in touch before or after the presentation. I will discuss some of the bits and pieces of some industry standard platforms which I’ve developed, deployed, maintained, managed, co-operated, administered and replaced. We can discuss some of the patterns that work well in the industry, and some that are a bit harder to tame.

    Once we have touched most of the areas of specialization represented at the meeting, I will dive in to an AngularJS demo I am developing in github here:

    https://github.com/LLC-Technologies-Collier/Demo-SCCC-Byte-AngularJS/tree/master

    To follow along with the presentation, please run these commands or something similar. My development environment is Debian stable. So yes, this means that we’re not doing a demo of the state of the art. But it also means that the infrastructure has been exercised under load and in production.

    Install Debian package dependencies

    First, install the debian packages of nodejs and npm, the node package manager:

    cjac@debian0:~$ sudo apt-get install nodejs nodejs-dev nodejs-legacy npm
    

    Check out the git repository

    After this, check out the repository from github and create a branch for your work:

    cjac@debian0:~$ mkdir -p /usr/src/git/github/LLC-Technologies-Collier
    cjac@debian0:~$ cd /usr/src/git/github/LLC-Technologies-Collier
    cjac@debian0:/usr/src/git/github/LLC-Technologies-Collier$ git clone git@github.com:LLC-Technologies-Collier/Demo-SCCC-Byte-AngularJS.git
    ...
    cjac@debian0:/usr/src/git/github/LLC-Technologies-Collier$ cd Demo-SCCC-Byte-AngularJS
    cjac@debian0:.../Demo-SCCC-Byte-AngularJS$ git checkout -b $USER
    

    Upgrade to latest npm, install deps

    Once we have the git repository checked out, we’ll grab the latest version of npm and the rest of the node modules

    cjac@debian0:.../Demo-SCCC-Byte-AngularJS$ export PATH="$PWD/node_modules/.bin:$PATH"
    cjac@debian0:.../Demo-SCCC-Byte-AngularJS$ npm install --save-exact npm@"2.1.0"
    cjac@debian0:.../Demo-SCCC-Byte-AngularJS$ npm install --save-exact `cat pkgackage-list.txt`
    

    This post and the associated git repository will be updated between now and the presentation on Thursday. Please chime in and feel free to get involved!

    C.J.

  • Regarding fdupes

    Dear readers,

    There is a very useful tool for finding and merging shared permanent storage, and its name is fdupes. There was a terrible occurrence in the software after version 1.51, however. They removed the -L argument because too many people were complaining about lost data. It sounds like user error to me, and so I continue to use this one. I have to build from source, since the newer versions do not have the -L option.

    https://github.com/tobiasschulz/fdupes

    And so there you are. I recommend using it, even though this most useful feature has been deprecated and removed from the software. Perhaps there should be a fdupes-danger package in Debian?

  • NIST::NVD CWE development – follow along

    I’m in the process of getting the tests passing for the 0.03 release of NIST::NVD::Store::SQLite3 wherein our hero imports the CWE data and cross-indexes it with CVEs and CPEs.

    Follow along and suggest some patches. I’m developing on Debian Wheezy, but I would very much like input from devs on other platforms.

    http://git.colliertech.org/?p=NIST-NVD-Store-SQLite3.git;a=summary

    cjac@foxtrot:/tmp$ time git clone http://git.colliertech.org/git/NIST-NVD-Store-SQLite3.git
    Cloning into 'NIST-NVD-Store-SQLite3'...
    
    real	0m32.757s
    user	0m0.200s
    sys	0m0.088s
    cjac@foxtrot:/tmp$ ls NIST-NVD-Store-SQLite3/t/data/
    cwec_v2.1.xml  nvdcve-2.0-test.xml
    

    Publish your patches and I’ll fetch them, or you can submit them in udiff format and I’ll review/apply. Thanks for playing along!

    [edit 20120216T1456 -0800]
    Seems I need to update the NIST::NVD package as well.

    cjac@foxtrot:/usr/src/git/f5/NIST-NVD-Store-SQLite3$ rm t/data/*.db *.db ; perl Makefile.PL ; make ; time perl -Iblib/lib /usr/src/git/f5/NIST-NVD-Store-SQLite3/blib/script/convert-nvdcve --nvd /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml --cwe /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/cwec_v2.1.xml --store SQLite3
    rm: cannot remove `t/data/*.db': No such file or directory
    Writing Makefile for NIST::NVD::Store::SQLite3
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/SQLite3.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::SQLite3.3pm
    using store [SQLite3]
    reading NVDs from file: /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml.......................................................................read 68 entries
    Processing CWE file...vvvvvvvvvvvvvvvvvvvvvvvvvvvcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwweeeeeeeeeDone.
    Writing CPE URNs to disk...Done.
    Writing NVD entries to disk....................................................................... Done.
    Writing CPE index to disk...Done.
    Writing CWE index to disk...Can't locate object method "put_idx_cwe" via package "NIST::NVD::Update" at /usr/src/git/f5/NIST-NVD-Store-SQLite3/blib/script/convert-nvdcve line 77.
    
    real	0m13.072s
    user	0m12.421s
    sys	0m0.044s
    
    $ time git clone http://git.colliertech.org/git/NIST-NVD.git
    Cloning into 'NIST-NVD'...
    
    real	0m2.921s
    user	0m0.016s
    sys	0m0.024s
    

    [edit 20120216T16:28 -0800]

    cjac@foxtrot:/usr/src/git/f5/NIST-NVD$ git log | head -5
    commit 82c72a79ee810c2b5c269a15dca5151ad67059f9
    Author: C.J. Adams-Collier 
    Date:   Thu Feb 16 16:25:53 2012 -0800
    
        added put_idx_cwe to NIST::NVD::Update
    

    [edit 20120216T1635 -0800]

    cjac@foxtrot:/usr/src/git/f5/NIST-NVD-Store-SQLite3$ rm t/data/*.db *.db ; perl Makefile.PL ; make ; time perl -Iblib/lib /usr/src/git/f5/NIST-NVD-Store-SQLite3/blib/script/convert-nvdcve --nvd /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml --cwe /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/cwec_v2.1.xml --store SQLite3
    rm: cannot remove `t/data/*.db': No such file or directory
    Writing Makefile for NIST::NVD::Store::SQLite3
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/SQLite3.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::SQLite3.3pm
    using store [SQLite3]
    reading NVDs from file: /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml.......................................................................read 68 entries
    Processing CWE file...vvvvvvvvvvvvvvvvvvvvvvvvvvvcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwweeeeeeeeeDone.
    Writing CPE URNs to disk...Done.
    Writing NVD entries to disk....................................................................... Done.
    Writing CPE index to disk...Done.
    Writing CWE index to disk...Done.
    
    real	0m13.968s
    user	0m13.225s
    sys	0m0.064s
    

    Alright. before going to bed, I made those “w” characters above mean something. Same with some of the “v” characters above.

    [edit 20120217T10:50 -0800]

    Now processing the Categories from the CWE files. At this point we have parsed the Description elements. Next up are:

    [edit 20120217T11:35 -0800]

    1. Likelihood_of_Exploit
    2. Time_of_Introduction
    3. Affected_Resources
    4. Applicable_Platforms
    cjac@foxtrot:/usr/src/git/f5/NIST-NVD-Store-SQLite3$ rm t/data/*.db *.db ; perl Makefile.PL ; make ; time perl -Iblib/lib /usr/src/git/f5/NIST-NVD-Store-SQLite3/blib/script/convert-nvdcve --nvd /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml --cwe /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/cwec_v2.1.xml --store SQLite3
    rm: cannot remove `t/data/*.db': No such file or directory
    Writing Makefile for NIST::NVD::Store::SQLite3
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/SQLite3.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::SQLite3.3pm
    using store [SQLite3]
    reading NVDs from file: /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml.......................................................................Done.
    read 68 nvd entries
    Processing CWE file...vvvvvvvvvvvvvvvvvvvvvvvvvvvvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcvDDDcwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwweeeeeeeeeDone.
    read 27 cwe Views
    read 1 cwe Categories
    read 693 cwe Weaknesses
    read 1 cwe Compound Elements
    Writing CPE URNs to disk...Done.
    Writing NVD entries to disk....................................................................... Done.
    Writing CPE index to disk...Done.
    Writing CWE index to disk...Done.
    
    real	0m14.306s
    user	0m13.501s
    sys	0m0.072s
    
    

    [edit 20120217T1333 -0800]

    Alright, I’ve got enough of the CWE processing done that I feel comfortable releasing this stuff. Let’s make sure that the data got all the way down into the database. I’ll write some tests in t/cwe.t to exercise the CRUD

    [edit 20120217T1345 -0800]

    Tests are in place and failing (this is good, by the way). Now to turn the tests green.

    cjac@foxtrot:/usr/src/git/f5/NIST-NVD-Store-SQLite3$ pushd ../NIST-NVD ; perl Makefile.PL ; make ; popd ; rm t/data/*.db *.db ; perl Makefile.PL ; make ; time prove -v -I../NIST-NVD/blib/lib -Iblib/lib t/cwe.t
    /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/svn/f5/axiom/branches/cjac/F5-Discovery
    Writing Makefile for NIST::NVD
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/Base.pm (unchanged)
    Skip blib/lib/NIST/NVD.pm (unchanged)
    Skip blib/lib/NIST/NVD/Query.pm (unchanged)
    Skip blib/lib/NIST/NVD/Update.pm (unchanged)
    Skip blib/lib/NIST/NVD/Store/DB_File.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::Base.3pm
    Manifying blib/man3/NIST::NVD.3pm
    Manifying blib/man3/NIST::NVD::Query.3pm
    Manifying blib/man3/NIST::NVD::Update.3pm
    Manifying blib/man3/NIST::NVD::Store::DB_File.3pm
    /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD-Store-SQLite3 /usr/src/svn/f5/axiom/branches/cjac/F5-Discovery
    rm: cannot remove `t/data/*.db': No such file or directory
    Writing Makefile for NIST::NVD::Store::SQLite3
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/SQLite3.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::SQLite3.3pm
    t/cwe.t .. 
    1..10
    ok 1 - use NIST::NVD::Query;
    ok 2 - no error
    ok 3 - constructor returned an object of correct class
    not ok 4 - cve_for_cpe returned ARRAY ref
    
    #   Failed test 'cve_for_cpe returned ARRAY ref'
    #   at t/cwe.t line 36.
    #          got: ''
    #     expected: 'ARRAY'
    not ok 5 - cwe_for_cpe returned ARRAY ref
    
    #   Failed test 'cwe_for_cpe returned ARRAY ref'
    #   at t/cwe.t line 37.
    #          got: ''
    #     expected: 'ARRAY'
    Can't use an undefined value as an ARRAY reference at t/cwe.t line 39.
    # Looks like you planned 10 tests but ran 5.
    # Looks like you failed 2 tests of 5 run.
    # Looks like your test exited with 2 just after 5.
    Dubious, test returned 2 (wstat 512, 0x200)
    Failed 7/10 subtests 
    
    Test Summary Report
    -------------------
    t/cwe.t (Wstat: 512 Tests: 5 Failed: 2)
      Failed tests:  4-5
      Non-zero exit status: 2
      Parse errors: Bad plan.  You planned 10 tests but ran 5.
    Files=1, Tests=5,  1 wallclock secs ( 0.02 usr  0.00 sys +  0.07 cusr  0.01 csys =  0.10 CPU)
    Result: FAIL
    
    real	0m0.442s
    user	0m0.144s
    sys	0m0.028s
    
    

    [edit 20120220T1311 -0800]

    CWE load is passing. It takes 13 seconds to process all CWEs in cwec_v2.1.xml and some recent CVEs from the 13th of December of 2011. It seems I’ve broken t/query.t, though. When it’s green I’ll push a new release. Everything is in master. Check it out if you like pain.

    cjac@foxtrot:/usr/src/git/f5/NIST-NVD-Store-SQLite3$ rm t/data/*.db ; pushd ../NIST-NVD/ ; perl Makefile.PL ; make ; popd ; perl -I../NIST-NVD/blib/lib Makefile.PL ; make ; PERL5LIB=../NIST-NVD/blib/lib:blib/lib prove -I../NIST-NVD/blib/lib -bv t/01-load-nvdcve.t 
    /usr/src/git/f5/NIST-NVD /usr/src/git/f5/NIST-NVD-Store-SQLite3
    Writing Makefile for NIST::NVD
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/Base.pm (unchanged)
    Skip blib/lib/NIST/NVD.pm (unchanged)
    Skip blib/lib/NIST/NVD/Query.pm (unchanged)
    Skip blib/lib/NIST/NVD/Update.pm (unchanged)
    Skip blib/lib/NIST/NVD/Store/DB_File.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::Base.3pm
    Manifying blib/man3/NIST::NVD.3pm
    Manifying blib/man3/NIST::NVD::Query.3pm
    Manifying blib/man3/NIST::NVD::Update.3pm
    Manifying blib/man3/NIST::NVD::Store::DB_File.3pm
    /usr/src/git/f5/NIST-NVD-Store-SQLite3
    Writing Makefile for NIST::NVD::Store::SQLite3
    Writing MYMETA.yml and MYMETA.json
    Skip blib/lib/NIST/NVD/Store/SQLite3.pm (unchanged)
    cp bin/convert-nvdcve blib/script/convert-nvdcve
    /usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/convert-nvdcve
    Manifying blib/man3/NIST::NVD::Store::SQLite3.3pm
    t/01-load-nvdcve.t .. 
    1..20
    ok 1 - $dist_dir is a directory
    ok 2 - $test_dir is a directory
    ok 3 - $data_dir is a directory
    ok 4 - $convert_script is a file
    ok 5 - $nvd_source_file is a file
    ok 6 - $db_file does not yet exist
    # running /usr/src/git/f5/NIST-NVD-Store-SQLite3/blib/script/convert-nvdcve --nvd /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/nvdcve-2.0-test.xml --cwe /usr/src/git/f5/NIST-NVD-Store-SQLite3/t/data/cwec_v2.1.xml --store SQLite3 2>&1
    ok 7 - took less than 15 seconds to load CWE data: 13
    ok 8 - conversion script returned cleanly
    ok 9 - database file exists
    ok 10 - database file not empty
    ok 11 - database file readable
    ok 12 - database file writeable
    ok 13 - database file not executable
    ok 14 - file is correct type: [application/octet-stream]
    ok 15 - $mtime is close
    ok 16 - opened database file for reading
    ok 17 - file contents indicate correct type: [application/octet-stream]
    ok 18 - file contents indicate correct type: [application/octet-stream]
    ok 19 - file contents indicate correct type: [SQLite 3.x database]
    ok 20 - constructor returned an object of correct class
    ok
    All tests successful.
    Files=1, Tests=20, 13 wallclock secs ( 0.02 usr  0.02 sys + 12.78 cusr  0.07 csys = 12.89 CPU)
    Result: PASS
    
    

    [edit 20120220T2220 -0800]
    Okay, it’s published. I’ll need to factor the changes in to the DB_File storage engine as well.

    [edit 20120225T20:27 -0800]
    Just published an update. It probably works better.

    Next up is creating another index from cpe urn to cwe data

  • Hey, look. I got mcs to github before Miguel

    http://github.com/cjac/mcs

    I’m also hosting it on my own not-as-l33t git repo:

    http://git.colliertech.org/?p=mcs.git;a=summary

    Does this mean that I get a “cooler than Miguel” tee shirt?