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))
|
if ($data === null || !isset($data->records))
|
||||||
{
|
{
|
||||||
Console::echo("Invalid DNS records returned by Porkbun API:\n$records\n");
|
return $this->fail("Invalid DNS records returned by Porkbun API: " . $records);
|
||||||
return self::STATUS_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard those records that are not type "A":
|
// Discard those records that are not type "A":
|
||||||
|
|
@ -83,6 +82,11 @@ class UpdateDnsCommand
|
||||||
$updated = false;
|
$updated = false;
|
||||||
foreach ($filteredRecords as $record)
|
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... ");
|
Console::echo("Porkbun's DNS for $record->name is pointing to $record->content... ");
|
||||||
|
|
||||||
if ($record->content != $myIp)
|
if ($record->content != $myIp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue