Validate Porkbun responses defensively
This commit is contained in:
parent
448eebd1d6
commit
915393a4c8
|
|
@ -69,8 +69,7 @@ class UpdateDnsCommand
|
|||
|
||||
if ($data === null || !isset($data->records))
|
||||
{
|
||||
Console::echo("Invalid DNS records returned by Porkbun API:\n$records\n");
|
||||
return self::STATUS_ERROR;
|
||||
return $this->fail("Invalid DNS records returned by Porkbun API: " . $records);
|
||||
}
|
||||
|
||||
// Discard those records that are not type "A":
|
||||
|
|
@ -83,6 +82,11 @@ class UpdateDnsCommand
|
|||
$updated = false;
|
||||
foreach ($filteredRecords as $record)
|
||||
{
|
||||
if (!isset($record->id, $record->name, $record->content, $record->type))
|
||||
{
|
||||
return $this->fail("Porkbun API returned a malformed DNS record.");
|
||||
}
|
||||
|
||||
Console::echo("Porkbun's DNS for $record->name is pointing to $record->content... ");
|
||||
|
||||
if ($record->content != $myIp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue