debian-forge/assemblers
Christian Kellner 01ce01b1c7 stages & assemblers: don't allow additional props
Change all the schemata to not allow additional properties. This
should help with misspelled properties as well as missing schema
information in the stage itself.

Done via a small python3 script:

   --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

import os
import sys

def list_stages(base):
    return [(base, f) for f in os.listdir(base) if f.startswith("org.osbuild")]

stages = list_stages("stages")
stages += list_stages("assemblers")

def find_line(lines, start):
    for i, l in enumerate(lines):
        if l.startswith(start):
            return i
    return None

NOADD = '"additionalProperties": false'

for stage in stages:
    with open(f"{stage[0]}/{stage[1]}", "r") as f:
        print(f"{stage[0]}/{stage[1]}", file=sys.stderr)
        data = f.readlines()
        i = find_line(data, 'STAGE_OPTS = """')
        if i:
            data.insert(i+1, NOADD + ",\n")
        else:
            i = find_line(data, 'STAGE_OPTS = ""')
            if i:
                data[i] = f'STAGE_OPTS = """\n'
                data.insert(i+1, NOADD + "\n")
                data.insert(i+2, '"""\n')

    with open(f"{stage[0]}/{stage[1]}", "w") as f:
        f.writelines(data)
2020-05-06 15:42:23 +02:00
..
org.osbuild.noop stages & assemblers: don't allow additional props 2020-05-06 15:42:23 +02:00
org.osbuild.ostree.commit stages & assemblers: don't allow additional props 2020-05-06 15:42:23 +02:00
org.osbuild.qemu stages & assemblers: don't allow additional props 2020-05-06 15:42:23 +02:00
org.osbuild.rawfs stages & assemblers: don't allow additional props 2020-05-06 15:42:23 +02:00
org.osbuild.tar stages & assemblers: don't allow additional props 2020-05-06 15:42:23 +02:00