Propose Db2 SELECT output guards

Proprietary

Guard a full copy of one SELECT output under an explicit approved result policy. Require SQLCODE zero and the exact output indicator zero. Require exact caller and ordinary COPY snapshots, one plain selected column, resolved ordinary hosts, matching approved diagnostics and inactive WHENEVER handlers. Require a PIC X output and its signed two-byte binary indicator. Keep input hosts and the copy destination separate from output, indicator and diagnostic storage. Accept one structure qualifier. Reject input indicators, multiple outputs, expressions, aliases and incomplete source. Insert a typed IF before the full equal-width MOVE. Support shared sentences and preserve every original byte and period. Reject every other result through the approved existing terminal exit. Independently prove the changed tree requires both zero values before the exact original copy. Existing complete checks remain unchanged. Support up to seven adjacent IF or EVALUATE checks when their complete result domain still permits a rejected outcome before the exact copy. EVALUATE selects bounded SQLCODE literals with ordered first-match behavior. Preserve exact values and indicator correlations across successive selections. Support complete SQLCODE comparisons with integer literals, AND, OR and NOT. Unknown conditions and intervening effects remain unresolved without findings. Eight incomplete checks can establish a finding but leave no room for a proposed guard within the eight-check proof. Existing checks that exclude every approved outcome also prevent a proposal. Report conditional CWE-252 only when a proven continuation to the output copy still permits a result rejected by the approved policy. An unproven exit or insertion leaves a finding without an edit. Application-team review remains required. The approved contract supplies the null and truncation policy. No universal null rejection, warning handling or not-found behavior is inferred. This does not establish SQL execution, database type compatibility, business validity, authorization, later use or transaction completion. Do not add retries, commits, rollbacks, ABEND or new error routines. Limit each condition to 64 atomic comparisons and the sequence to 1024 distinct nonzero SQLCODE literals. Ordered comparisons preserve exact integer intervals. They require every SQLCODE boundary in the sequence to have an absolute value no greater than 999999998. Unsupported expressions remain unresolved.

io.moderne.mainframe.security.ProposeDb2SelectOutputGuard

Required

Exact approved caller path.

Exact program ID. Retain quotes for a literal ID.

Lowercase SHA-256 of the complete approved UTF-8 caller without a byte order mark.

JSON object mapping every ordinary data COPY name to its approved lowercase SHA-256. The independently validated system SQLCA is excluded.

One-based SELECT line in the approved source.

One-based full output MOVE line covered by the approved policy.

Exact unquoted uppercase schema and table name.

Explicitly approved STDSQL(YES) or STDSQL(NO). Require matching standalone diagnostics or standard system SQLCA declarations.

Explicit approval that only SQLCODE zero and indicator zero permit this exact output copy. Supply SQLCODE_ZERO_AND_INDICATOR_ZERO. This policy must account for null, truncation, warning and not-found outcomes at this site.

Existing paragraph approved for every result rejected by this policy. An optional IN or OF section qualifier is supported. Preserve required messages, cleanup and transaction behavior.

Provenance of the independently approved processing mode, result policy, output copy and failure exit at these exact snapshots. The recipe records this input and does not infer or fetch approval.

mod run . --recipe=io.moderne.mainframe.security.ProposeDb2SelectOutputGuard \ -P sourcePath=security/cbl/VSOGGOOD.cbl \ -P programName=VSOGGOOD \ -P sourceSha256=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \ -P copybookSnapshots='{}' \ -P selectLine=19 \ -P copyLine=25 \ -P tableName=VTEST.ITEM \ -P diagnosticMode='STDSQL(YES)' \ -P acceptedResultPolicy=SQLCODE_ZERO_AND_INDICATOR_ZERO \ -P approvedExit=SQL-ERROR-EXIT \ -P contractSource='mainframe-fixtures fictional approved SELECT output contract'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.