mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 03:56:15 -08:00
fix(packaging): reject ambiguous Snap memory metadata
This commit is contained in:
1 parent
5b168866e4
commit
489c9dee89
2 files changed
+48
-1
No files matched your search
@@ -546,6 +546,21 @@ export function validateExtractedSnapMetadata(extractionRoot) {
|
||||
}
|
||||
|
||||
const plugEntries = directYamlMappingEntries(lines, plugs, 2);
|
||||
if (
|
||||
!plugEntries ||
|
||||
plugEntries.some(({ value }) => value.length > 0)
|
||||
) {
|
||||
errors.push(
|
||||
'Extracted Snap plug declarations must use block mappings.'
|
||||
);
|
||||
}
|
||||
if (
|
||||
plugEntries &&
|
||||
new Set(plugEntries.map(({ key }) => key)).size !==
|
||||
plugEntries.length
|
||||
) {
|
||||
errors.push('Extracted Snap direct plug keys must be unique.');
|
||||
}
|
||||
const sharedMemoryInterfaces =
|
||||
plugEntries?.filter((plugEntry) => {
|
||||
const plugFields = directYamlMappingEntries(
|
||||
@@ -582,12 +597,18 @@ export function validateExtractedSnapMetadata(extractionRoot) {
|
||||
lines.length
|
||||
);
|
||||
let hasSharedMemorySlot = slotsEntries.length > 1;
|
||||
let invalidSlotsShape = slotsEntries.some(
|
||||
({ value }) => value.length > 0
|
||||
);
|
||||
for (const slots of slotsEntries) {
|
||||
const slotEntries = directYamlMappingEntries(lines, slots, 2);
|
||||
if (!slotEntries) {
|
||||
hasSharedMemorySlot = true;
|
||||
invalidSlotsShape = true;
|
||||
continue;
|
||||
}
|
||||
invalidSlotsShape ||= slotEntries.some(
|
||||
({ value }) => value.length > 0
|
||||
);
|
||||
hasSharedMemorySlot ||= slotEntries.some((slotEntry) => {
|
||||
if (slotEntry.key === 'shared-memory') {
|
||||
return true;
|
||||
@@ -602,6 +623,11 @@ export function validateExtractedSnapMetadata(extractionRoot) {
|
||||
);
|
||||
});
|
||||
}
|
||||
if (invalidSlotsShape) {
|
||||
errors.push(
|
||||
'Extracted Snap slots must use block mappings with scalar fields.'
|
||||
);
|
||||
}
|
||||
if (hasSharedMemorySlot) {
|
||||
errors.push(
|
||||
'Extracted Snap metadata must not declare a shared-memory slot.'
|
||||
|
||||
@@ -639,6 +639,27 @@ test('requires a private top-level shared-memory plug used by the Snap app', ()
|
||||
`${contents}slots:\n shared-memory:\n interface: shared-memory\n`,
|
||||
/must not declare.*shared-memory slot/i,
|
||||
],
|
||||
[
|
||||
(contents) =>
|
||||
contents.replace(
|
||||
'\nplugs:\n',
|
||||
'\nplugs:\n other: { interface: shared-memory }\n'
|
||||
),
|
||||
/plug declarations.*block mappings/i,
|
||||
],
|
||||
[
|
||||
(contents) =>
|
||||
`${contents}slots: { leak: { interface: shared-memory } }\n`,
|
||||
/slots.*block mappings/i,
|
||||
],
|
||||
[
|
||||
(contents) =>
|
||||
contents.replace(
|
||||
'\nplugs:\n',
|
||||
'\nplugs:\n network:\n interface: network\n network:\n interface: network\n'
|
||||
),
|
||||
/plug keys.*unique/i,
|
||||
],
|
||||
[
|
||||
(contents) =>
|
||||
contents.replace(
|
||||
|
||||
Reference in new issue
Block a user