dkim_sign.lua: make base and domain optional

When splitting the config across multiple files, we should not
raise an error if the base or domain section is missing from
the file that is currently being processed.

Let's also show which file is currently being processed.
This commit is contained in:
Wez Furlong
2024-09-03 14:54:09 -07:00
parent 5f9e74e2b4
commit b5eb78b72b
2 changed files with 13 additions and 5 deletions
+9 -5
View File
@@ -19,7 +19,7 @@ local SignatureSigningPolicy =
local SigningAlgo = typing.enum('SigningAlgo', 'sha256', 'ed25519')
local DkimSignConfig = Record('DkimSignConfig', {
base = Record('DkimSignConfig.Base', {
base = Option(Record('DkimSignConfig.Base', {
vault_mount = Option(String),
vault_path_prefix = Option(String),
additional_signatures = Option(List(String)),
@@ -29,9 +29,9 @@ local DkimSignConfig = Record('DkimSignConfig', {
header_canonicalization = Option(String),
body_canonicalization = Option(String),
over_sign = Option(Bool),
}),
})),
domain = typing.map(
domain = Option(typing.map(
String,
Record('DkimSignConfig.Domain', {
selector = Option(String),
@@ -43,7 +43,7 @@ local DkimSignConfig = Record('DkimSignConfig', {
body_canonicalization = Option(String),
over_sign = Option(Bool),
})
),
)),
signature = Option(typing.map(
String,
@@ -129,7 +129,11 @@ domain = "myesp.com"
]]
local function load_dkim_data_from_file(file_name, target)
local data = DkimSignConfig(utils.load_json_or_toml_file(file_name))
local raw_data = utils.load_json_or_toml_file(file_name)
local is_ok, data = pcall(DkimSignConfig, raw_data)
if not is_ok then
error(string.format("reading data from file '%s': %s'", file_name, data))
end
if data.base then
utils.merge_into(data.base, target.base)
+4
View File
@@ -40,3 +40,7 @@
`0ns` for sessions for which we had not observed the session opening. Now we
will assume a start time time of the first record observed for a session, so
that some sense of relative time can be gleaned from the trace output.
* When using the dkim helper and splitting the configuration
across multiple files, a missing `domain` or `base` configuration section in
any individual file would raise a validation error.