From 97db2e8879a31f6640392a5e6319ae8ee16f5314 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 17 Mar 2020 10:34:08 -0700 Subject: [PATCH 01/27] Added PHP code samples for SecurityCenter --- securitycenter/composer.json | 10 ++ securitycenter/phpunit.xml.dist | 42 +++++++ securitycenter/src/create_notification.php | 56 +++++++++ securitycenter/src/delete_notification.php | 45 ++++++++ securitycenter/src/get_notification.php | 44 +++++++ securitycenter/src/list_notification.php | 49 ++++++++ securitycenter/src/receive_notification.php | 45 ++++++++ securitycenter/src/update_notification.php | 61 ++++++++++ securitycenter/test/securitycenterTest.php | 121 ++++++++++++++++++++ 9 files changed, 473 insertions(+) create mode 100644 securitycenter/composer.json create mode 100644 securitycenter/phpunit.xml.dist create mode 100644 securitycenter/src/create_notification.php create mode 100644 securitycenter/src/delete_notification.php create mode 100644 securitycenter/src/get_notification.php create mode 100644 securitycenter/src/list_notification.php create mode 100644 securitycenter/src/receive_notification.php create mode 100644 securitycenter/src/update_notification.php create mode 100644 securitycenter/test/securitycenterTest.php diff --git a/securitycenter/composer.json b/securitycenter/composer.json new file mode 100644 index 0000000000..98d2162bf0 --- /dev/null +++ b/securitycenter/composer.json @@ -0,0 +1,10 @@ +{ + + "require": { + "google/cloud-security-center": "^0.5.0", + "google/cloud-pubsub": "^1.21" + }, + "require-dev": { + "phpunit/phpunit": "^8" + } +} diff --git a/securitycenter/phpunit.xml.dist b/securitycenter/phpunit.xml.dist new file mode 100644 index 0000000000..d59be6c31b --- /dev/null +++ b/securitycenter/phpunit.xml.dist @@ -0,0 +1,42 @@ + + + + + + test + + + + + + + + ./src + + ./vendor + + + + diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php new file mode 100644 index 0000000000..ecc9be48fc --- /dev/null +++ b/securitycenter/src/create_notification.php @@ -0,0 +1,56 @@ +setFilter("state = \"ACTIVE\""); + $notificationConfig = new NotificationConfig(); + $notificationConfig->setDescription("PHP notification config"); + $notificationConfig->setPubsubTopic($pubsubTopic); + $notificationConfig->setStreamingConfig($streamingConfig); + + $response = $securityCenterClient->createNotificationConfig($organizationName, $notificationConfigId, $notificationConfig); + printf("Notification config was created: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_create_notification_config] \ No newline at end of file diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php new file mode 100644 index 0000000000..bb1c290577 --- /dev/null +++ b/securitycenter/src/delete_notification.php @@ -0,0 +1,45 @@ +deleteNotificationConfig($notificationConfigName); + printf("Notification config was deleted"); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_delete_notification_config] \ No newline at end of file diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php new file mode 100644 index 0000000000..9223fb9f51 --- /dev/null +++ b/securitycenter/src/get_notification.php @@ -0,0 +1,44 @@ +getNotificationConfig($notificationConfigName); + printf("Notification config was retrieved: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} +// [END scc_get_notification_config] \ No newline at end of file diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php new file mode 100644 index 0000000000..ee21368cd1 --- /dev/null +++ b/securitycenter/src/list_notification.php @@ -0,0 +1,49 @@ +listNotificationConfigs($organizationName); + $count = 0; + foreach ($pagedResponse->iterateAllElements() as $element) { + $count += 1; + } + + printf("Notification configs were listed"); + return $count; + +} finally { + $securityCenterClient->close(); +} + +// [END scc_list_notification_configs] \ No newline at end of file diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php new file mode 100644 index 0000000000..adfeeb5a46 --- /dev/null +++ b/securitycenter/src/receive_notification.php @@ -0,0 +1,45 @@ +subscription($projectSubscriptionName); + +$pubsub = new PubSubClient([ + 'projectId' => $projectId, +]); + +foreach ($subscription->pull() as $message) { + printf('Message: %s' . PHP_EOL, $message->data()); + // Acknowledge the Pub/Sub message has been received, so it will not be pulled multiple times. + $subscription->acknowledge($message); +} +// [END scc_receive_notifications] \ No newline at end of file diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php new file mode 100644 index 0000000000..76f8b4ea36 --- /dev/null +++ b/securitycenter/src/update_notification.php @@ -0,0 +1,61 @@ +setFilter("state = \"ACTIVE\""); + $notificationConfig = new NotificationConfig(); + $notificationConfig->setName($notificationConfigName); + $notificationConfig->setDescription("Updated description."); + $notificationConfig->setPubsubTopic($pubsubTopic); + $fieldMask = new FieldMask(); + $fieldMask->setPaths(array("description", "pubsub_topic")); + + $response = $securityCenterClient->updateNotificationConfig($notificationConfig, array($fieldMask)); + printf("Notification config was updated: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_update_notification_config] \ No newline at end of file diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php new file mode 100644 index 0000000000..1235188ef7 --- /dev/null +++ b/securitycenter/test/securitycenterTest.php @@ -0,0 +1,121 @@ +runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-create", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-create", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + } + + public function testGetNotificationConfig() + { + $createOutput = $this->runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $getOutput = $this->runSnippet('get_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + ]); + + $this->assertContains('Notification config was retrieved', $getOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + + } + + public function testUpdateNotificationConfig() + { + $createOutput = $this->runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $getOutput = $this->runSnippet('update_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was updated', $getOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + + } + + public function testListNotificationConfig() + { + $listOutput = $this->runSnippet('list_notification', [ + self::getOrganizationId(), + ]); + + $this->assertContains('Notification configs were listed', $listOutput); + + } + + private static function getOrganizationId() { + return "1081635000895"; + } + + private static function getProject() { + return "project-a-id"; + } + + private static function getTopicName() { + return "notifications-sample-topic"; + } +} \ No newline at end of file From 58ee1910c714bdecad1d0cea48c1d6d5c0b19074 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Mon, 30 Mar 2020 13:19:18 -0700 Subject: [PATCH 02/27] Addressed first comments --- securitycenter/composer.json | 2 - securitycenter/src/create_notification.php | 6 +- securitycenter/src/delete_notification.php | 5 +- securitycenter/src/get_notification.php | 5 +- securitycenter/src/list_notification.php | 3 +- securitycenter/src/receive_notification.php | 5 +- securitycenter/src/update_notification.php | 5 +- securitycenter/test/securitycenterTest.php | 78 +++++++++++---------- 8 files changed, 53 insertions(+), 56 deletions(-) diff --git a/securitycenter/composer.json b/securitycenter/composer.json index 98d2162bf0..6d4a4167cc 100644 --- a/securitycenter/composer.json +++ b/securitycenter/composer.json @@ -1,10 +1,8 @@ { - "require": { "google/cloud-security-center": "^0.5.0", "google/cloud-pubsub": "^1.21" }, "require-dev": { - "phpunit/phpunit": "^8" } } diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index ecc9be48fc..3fee395247 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -17,17 +17,15 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 4) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_create_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use \Google\Cloud\SecurityCenter\V1\NotificationConfig; - /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; // $notificationConfigId = {"your-unique-id"}; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index bb1c290577..1755de1f2f 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_delete_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 9223fb9f51..fc1e90247d 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_get_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index ee21368cd1..317f9ea24f 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -18,12 +18,11 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); + return printf("Usage: php %s ORGANIZATION_ID\n", basename(__FILE__)); } list($_, $organizationId) = $argv; // [START scc_list_notification_configs] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index adfeeb5a46..eddde99ed0 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n", basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; // [START scc_receive_notifications] - use Google\Cloud\PubSub\PubSubClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 76f8b4ea36..60ab435c60 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 4) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use \Google\Cloud\SecurityCenter\V1\NotificationConfig; use \Google\Protobuf\FieldMask; diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php index 1235188ef7..64a44c147e 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/securitycenterTest.php @@ -22,31 +22,47 @@ class securitycenterTest extends TestCase { use TestTrait; + private static $testNotificationCreate; + private static $testNotificationGet; + private static $testNotificationUpdate; + + public static function setUpBeforeClass() + { + self::$testNotificationCreate = self::randomNotificationId(); + self::$testNotificationGet = self::randomNotificationId(); + self::$testNotificationUpdate = self::randomNotificationId(); + } + + private function deleteConfig(string $configId) + { + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + $configId, + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + } + public function testCreateNotification() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-create", - self::getProject(), + self::$testNotificationCreate, + self::$projectId, self::getTopicName() ]); $this->assertContains('Notification config was created', $createOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-create", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); + self::deleteConfig(self::$testNotificationCreate); } public function testGetNotificationConfig() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-get", - self::getProject(), + self::$testNotificationGet, + self::$projectId, self::getTopicName() ]); @@ -54,26 +70,20 @@ public function testGetNotificationConfig() $getOutput = $this->runSnippet('get_notification', [ self::getOrganizationId(), - "php-notification-config-get", + self::$testNotificationGet ]); $this->assertContains('Notification config was retrieved', $getOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-get", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); - + self::deleteConfig(self::$testNotificationGet); } public function testUpdateNotificationConfig() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-update", - self::getProject(), + self::$testNotificationUpdate, + self::$projectId, self::getTopicName() ]); @@ -81,20 +91,14 @@ public function testUpdateNotificationConfig() $getOutput = $this->runSnippet('update_notification', [ self::getOrganizationId(), - "php-notification-config-update", - self::getProject(), + self::$testNotificationUpdate, + self::$projectId, self::getTopicName() ]); $this->assertContains('Notification config was updated', $getOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-update", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); - + self::deleteConfig(self::$testNotificationUpdate); } public function testListNotificationConfig() @@ -104,18 +108,20 @@ public function testListNotificationConfig() ]); $this->assertContains('Notification configs were listed', $listOutput); - } - private static function getOrganizationId() { - return "1081635000895"; + private static function getOrganizationId() + { + return self::requireEnv('GOOGLE_ORGANIZATION_ID'); } - private static function getProject() { - return "project-a-id"; + private static function getTopicName() + { + return self::requireEnv('GOOGLE_TOPIC_ID'); } - private static function getTopicName() { - return "notifications-sample-topic"; + private static function randomNotificationId() + { + return uniqid('php-notification-config-'); } } \ No newline at end of file From 8fd59b695f23787f460331ca0408c7c99028152d Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 10:57:13 -0700 Subject: [PATCH 03/27] Removed required dev --- securitycenter/composer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/securitycenter/composer.json b/securitycenter/composer.json index 6d4a4167cc..32fff1ac26 100644 --- a/securitycenter/composer.json +++ b/securitycenter/composer.json @@ -2,7 +2,5 @@ "require": { "google/cloud-security-center": "^0.5.0", "google/cloud-pubsub": "^1.21" - }, - "require-dev": { } } From 70e3ece335b88db00dada999142b1875eaa235f7 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 11:00:53 -0700 Subject: [PATCH 04/27] Removed /'s --- securitycenter/src/create_notification.php | 4 ++-- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/update_notification.php | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 3fee395247..0f31124316 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -23,8 +23,8 @@ list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_create_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; -use \Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\NotificationConfig; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 1755de1f2f..6d20a5511f 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_delete_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index fc1e90247d..fc62943079 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_get_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 317f9ea24f..0a23b00371 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId) = $argv; // [START scc_list_notification_configs] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 60ab435c60..7e274548a4 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -23,9 +23,9 @@ list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; -use \Google\Cloud\SecurityCenter\V1\NotificationConfig; -use \Google\Protobuf\FieldMask; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Protobuf\FieldMask; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; From bfbabe3c3b6e5e894379519a4c1a85586135a9f7 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 13:57:47 -0700 Subject: [PATCH 05/27] Fixed remaining comments --- securitycenter/src/create_notification.php | 38 +++++++------- securitycenter/src/delete_notification.php | 26 +++++----- securitycenter/src/get_notification.php | 25 +++++---- securitycenter/src/list_notification.php | 27 ++++------ securitycenter/src/receive_notification.php | 10 ++-- securitycenter/src/update_notification.php | 56 ++++++++++----------- 6 files changed, 84 insertions(+), 98 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 0f31124316..a8e94ef219 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; @@ -33,22 +33,22 @@ // $topicName = "{your-topic}"; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$pubsubTopic = "projects/" . $projectId . "/topics/" . $topicName; - -try { - $streamingConfig = new NotificationConfig\StreamingConfig(); - $streamingConfig->setFilter("state = \"ACTIVE\""); - $notificationConfig = new NotificationConfig(); - $notificationConfig->setDescription("PHP notification config"); - $notificationConfig->setPubsubTopic($pubsubTopic); - $notificationConfig->setStreamingConfig($streamingConfig); - - $response = $securityCenterClient->createNotificationConfig($organizationName, $notificationConfigId, $notificationConfig); - printf("Notification config was created: %s", $response->getName()); - -} finally { - $securityCenterClient->close(); -} - +$organizationName = $securityCenterClient::organizationName($organizationId); +$pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); + +$streamingConfig = new NotificationConfig\StreamingConfig(); +$streamingConfig->setFilter("state = \"ACTIVE\""); +$notificationConfig = new NotificationConfig(); +$notificationConfig->setDescription('A sample notification config'); +$notificationConfig->setPubsubTopic($pubsubTopic); +$notificationConfig->setStreamingConfig($streamingConfig); + +$response = $securityCenterClient->createNotificationConfig( + $organizationName, + $notificationConfigId, + $notificationConfig +); +printf('Notification config was created: %s', $response->getName()); + +$securityCenterClient->close(); // [END scc_create_notification_config] \ No newline at end of file diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 6d20a5511f..9ba31782df 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; @@ -26,19 +26,17 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; +$notificationConfigName = $securityCenterClient::notificationConfigName( + $organizationId, + $notificationConfigId +); -try { - $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); - printf("Notification config was deleted"); - -} finally { - $securityCenterClient->close(); -} +$response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); +print('Notification config was deleted'); +$securityCenterClient->close(); // [END scc_delete_notification_config] \ No newline at end of file diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index fc62943079..155c142c61 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; @@ -26,18 +26,17 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; +$notificationConfigName = $securityCenterClient::notificationConfigName( + $organizationId, + $notificationConfigId +); -try { - $response = $securityCenterClient->getNotificationConfig($notificationConfigName); - printf("Notification config was retrieved: %s", $response->getName()); +$response = $securityCenterClient->getNotificationConfig($notificationConfigName); +printf('Notification config was retrieved: %s', $response->getName()); -} finally { - $securityCenterClient->close(); -} +$securityCenterClient->close(); // [END scc_get_notification_config] \ No newline at end of file diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 0a23b00371..91f138cc1d 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf("Usage: php %s ORGANIZATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); } list($_, $organizationId) = $argv; @@ -26,23 +26,16 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; +// $organizationId = '{your-org-id}'; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; +$organizationName = $securityCenterClient::organizationName($organizationId); -try { - $pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); - $count = 0; - foreach ($pagedResponse->iterateAllElements() as $element) { - $count += 1; - } - - printf("Notification configs were listed"); - return $count; - -} finally { - $securityCenterClient->close(); +$pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); +foreach ($pagedResponse->iterateAllElements() as $element) { + printf('Found notification config %s', $element->getName()); } +print('Notification configs were listed'); +$securityCenterClient->close(); // [END scc_list_notification_configs] \ No newline at end of file diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index eddde99ed0..b0a26c6182 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n", basename(__FILE__)); + return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; @@ -26,15 +26,13 @@ use Google\Cloud\PubSub\PubSubClient; /** Uncomment and populate these variables in your code */ -// String projectId = "{your-project}"; -// String subscriptionId = "{your-subscription}"; - -$projectSubscriptionName = "projects/" . $projectId . "/subscriptions/" . $subscriptionId; -$subscription = $pubsub->subscription($projectSubscriptionName); +// $projectId = "{your-project-id}"; +// $subscriptionId = "{your-subscription-id}"; $pubsub = new PubSubClient([ 'projectId' => $projectId, ]); +$subscription = $pubsub->subscription($subscriptionId); foreach ($subscription->pull() as $message) { printf('Message: %s' . PHP_EOL, $message->data()); diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 7e274548a4..e7efb5c87a 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,43 +18,41 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\NotificationConfig\StreamingConfig; use Google\Protobuf\FieldMask; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; -// $projectId = "{your-project}""; -// $topicName = "{your-topic}"; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; +// $projectId = '{your-project}'; +// $topicName = '{your-topic}'; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; - -// Ensure this ServiceAccount has the "pubsub.topics.setIamPolicy" permission on the topic. -$pubsubTopic = "projects/" . $projectId . "/topics/" . $topicName; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; - -try { - $streamingConfig = new NotificationConfig\StreamingConfig(); - $streamingConfig->setFilter("state = \"ACTIVE\""); - $notificationConfig = new NotificationConfig(); - $notificationConfig->setName($notificationConfigName); - $notificationConfig->setDescription("Updated description."); - $notificationConfig->setPubsubTopic($pubsubTopic); - $fieldMask = new FieldMask(); - $fieldMask->setPaths(array("description", "pubsub_topic")); - - $response = $securityCenterClient->updateNotificationConfig($notificationConfig, array($fieldMask)); - printf("Notification config was updated: %s", $response->getName()); - -} finally { - $securityCenterClient->close(); -} +// Ensure this ServiceAccount has the 'pubsub.topics.setIamPolicy' permission on the topic. +// https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/setIamPolicy +$pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); +$notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); + +$streamingConfig = new StreamingConfig(); +$streamingConfig->setFilter("state = \"ACTIVE\""); +$fieldMask = new FieldMask(); +$fieldMask->setPaths(['description', 'pubsub_topic']); +$notificationConfig = new NotificationConfig(); +$notificationConfig + ->setName($notificationConfigName) + ->setDescription('Updated description.') + ->setPubsubTopic($pubsubTopic); + +$response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); +printf('Notification config was updated: %s', $response->getName()); + +$securityCenterClient->close(); // [END scc_update_notification_config] \ No newline at end of file From f97d502437d3e23766eafc0da5f3e4a860715681 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 13:49:05 -0700 Subject: [PATCH 06/27] Addressed remaining comments --- .kokoro/secrets-example.sh | 4 ++++ securitycenter/src/create_notification.php | 14 +++++++------- securitycenter/src/delete_notification.php | 3 +-- securitycenter/src/get_notification.php | 3 +-- securitycenter/src/list_notification.php | 9 ++++----- securitycenter/src/receive_notification.php | 3 ++- securitycenter/src/update_notification.php | 6 ++---- securitycenter/test/securitycenterTest.php | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 88710d0c69..6db7d34bea 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -100,6 +100,10 @@ export REDIS_PORT= export GOOGLE_PUBSUB_SUBSCRIPTION=php-example-subscription export GOOGLE_PUBSUB_TOPIC=php-example-topic +# Security Center +export GOOGLE_ORGANIZATION_ID= +export GOOGLE_PUBSUB_TOPIC=php-example-topic + # Spanner export GOOGLE_SPANNER_INSTANCE_ID= export GOOGLE_SPANNER_DATABASE_ID=test-database diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index a8e94ef219..ee310b5a5e 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -25,6 +25,7 @@ // [START scc_create_notification_config] use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\NotificationConfig\StreamingConfig; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; @@ -36,12 +37,12 @@ $organizationName = $securityCenterClient::organizationName($organizationId); $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); -$streamingConfig = new NotificationConfig\StreamingConfig(); +$streamingConfig = new StreamingConfig(); $streamingConfig->setFilter("state = \"ACTIVE\""); -$notificationConfig = new NotificationConfig(); -$notificationConfig->setDescription('A sample notification config'); -$notificationConfig->setPubsubTopic($pubsubTopic); -$notificationConfig->setStreamingConfig($streamingConfig); +$notificationConfig = (new NotificationConfig()) + ->setDescription('A sample notification config') + ->setPubsubTopic($pubsubTopic) + ->setStreamingConfig($streamingConfig); $response = $securityCenterClient->createNotificationConfig( $organizationName, @@ -50,5 +51,4 @@ ); printf('Notification config was created: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_create_notification_config] \ No newline at end of file +// [END scc_create_notification_config] diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 9ba31782df..1c94f66c10 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -38,5 +38,4 @@ $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); print('Notification config was deleted'); -$securityCenterClient->close(); -// [END scc_delete_notification_config] \ No newline at end of file +// [END scc_delete_notification_config] diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 155c142c61..814abd1fcf 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -38,5 +38,4 @@ $response = $securityCenterClient->getNotificationConfig($notificationConfigName); printf('Notification config was retrieved: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_get_notification_config] \ No newline at end of file +// [END scc_get_notification_config] diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 91f138cc1d..666d091505 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -31,11 +31,10 @@ $securityCenterClient = new SecurityCenterClient(); $organizationName = $securityCenterClient::organizationName($organizationId); -$pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); -foreach ($pagedResponse->iterateAllElements() as $element) { - printf('Found notification config %s', $element->getName()); +foreach ($securityCenterClient->listNotificationConfigs($organizationName) as $element) { + printf('Found notification config %s' . PHP_EOL, $element->getName()); } print('Notification configs were listed'); -$securityCenterClient->close(); -// [END scc_list_notification_configs] \ No newline at end of file + +// [END scc_list_notification_configs] diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index b0a26c6182..0ccaefc31c 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -39,4 +39,5 @@ // Acknowledge the Pub/Sub message has been received, so it will not be pulled multiple times. $subscription->acknowledge($message); } -// [END scc_receive_notifications] \ No newline at end of file + +// [END scc_receive_notifications] diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index e7efb5c87a..8106561f89 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -45,8 +45,7 @@ $streamingConfig->setFilter("state = \"ACTIVE\""); $fieldMask = new FieldMask(); $fieldMask->setPaths(['description', 'pubsub_topic']); -$notificationConfig = new NotificationConfig(); -$notificationConfig +$notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') ->setPubsubTopic($pubsubTopic); @@ -54,5 +53,4 @@ $response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); printf('Notification config was updated: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_update_notification_config] \ No newline at end of file +// [END scc_update_notification_config] diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php index 64a44c147e..5d35dd52cd 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/securitycenterTest.php @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_TOPIC_ID'); + return self::requireEnv('GOOGLE_PUBSUB_TOPIC'); } private static function randomNotificationId() From c6533f08c797333422f42a9bdf362ee2c9ecbd5e Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 14:05:26 -0700 Subject: [PATCH 07/27] Added fluent setters --- securitycenter/src/create_notification.php | 3 +-- securitycenter/src/update_notification.php | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index ee310b5a5e..9f7ac0771a 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -37,8 +37,7 @@ $organizationName = $securityCenterClient::organizationName($organizationId); $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); -$streamingConfig = new StreamingConfig(); -$streamingConfig->setFilter("state = \"ACTIVE\""); +$streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); $notificationConfig = (new NotificationConfig()) ->setDescription('A sample notification config') ->setPubsubTopic($pubsubTopic) diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 8106561f89..37c1dbca89 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -41,10 +41,8 @@ $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); $notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); -$streamingConfig = new StreamingConfig(); -$streamingConfig->setFilter("state = \"ACTIVE\""); -$fieldMask = new FieldMask(); -$fieldMask->setPaths(['description', 'pubsub_topic']); +$streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); +$fieldMask = (new FieldMask())>setPaths(['description', 'pubsub_topic']); $notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') From 0ecb02f0ae075b787d6cb40f7a6c9f7e90b1a7d3 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 14:20:22 -0700 Subject: [PATCH 08/27] Fixed typo --- securitycenter/src/update_notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 37c1dbca89..30f367b0df 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -42,7 +42,7 @@ $notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); $streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); -$fieldMask = (new FieldMask())>setPaths(['description', 'pubsub_topic']); +$fieldMask = (new FieldMask())->setPaths(['description', 'pubsub_topic']); $notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') From f315260025936d89b40718098944811f4d6b3222 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:01:08 -0700 Subject: [PATCH 09/27] Addressed environment variable and EOL changes --- .kokoro/secrets-example.sh | 2 +- securitycenter/src/create_notification.php | 2 +- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/update_notification.php | 2 +- .../test/{securitycenterTest.php => SecurityCenterTest.php} | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) rename securitycenter/test/{securitycenterTest.php => SecurityCenterTest.php} (97%) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 6db7d34bea..3a42a7da33 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -102,7 +102,7 @@ export GOOGLE_PUBSUB_TOPIC=php-example-topic # Security Center export GOOGLE_ORGANIZATION_ID= -export GOOGLE_PUBSUB_TOPIC=php-example-topic +export GOOGLE_TOPIC_ID= # Spanner export GOOGLE_SPANNER_INSTANCE_ID= diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 9f7ac0771a..e815e5e816 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -48,6 +48,6 @@ $notificationConfigId, $notificationConfig ); -printf('Notification config was created: %s', $response->getName()); +printf('Notification config was created: %s' . PHP_EOL, $response->getName()); // [END scc_create_notification_config] diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 1c94f66c10..d6609b36d8 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -36,6 +36,6 @@ ); $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); -print('Notification config was deleted'); +print('Notification config was deleted' . PHP_EOL); // [END scc_delete_notification_config] diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 814abd1fcf..29edc71aa1 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -36,6 +36,6 @@ ); $response = $securityCenterClient->getNotificationConfig($notificationConfigName); -printf('Notification config was retrieved: %s', $response->getName()); +printf('Notification config was retrieved: %s' . PHP_EOL, $response->getName()); // [END scc_get_notification_config] diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 666d091505..dd7bc34754 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -35,6 +35,6 @@ printf('Found notification config %s' . PHP_EOL, $element->getName()); } -print('Notification configs were listed'); +print('Notification configs were listed' . PHP_EOL); // [END scc_list_notification_configs] diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 30f367b0df..9a51913ff7 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -49,6 +49,6 @@ ->setPubsubTopic($pubsubTopic); $response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); -printf('Notification config was updated: %s', $response->getName()); +printf('Notification config was updated: %s' . PHP_EOL, $response->getName()); // [END scc_update_notification_config] diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/SecurityCenterTest.php similarity index 97% rename from securitycenter/test/securitycenterTest.php rename to securitycenter/test/SecurityCenterTest.php index 5d35dd52cd..0e317cb1a9 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -18,7 +18,7 @@ use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; -class securitycenterTest extends TestCase +class securityCenterTest extends TestCase { use TestTrait; @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_PUBSUB_TOPIC'); + return self::requireEnv('GOOGLE_TOPIC_ID'); } private static function randomNotificationId() From 50c3cad24678454198b6bb0decc2a01741151be7 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:01:52 -0700 Subject: [PATCH 10/27] Changed pubsub topic name --- .kokoro/secrets-example.sh | 2 +- securitycenter/test/SecurityCenterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 3a42a7da33..287eb010cc 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -102,7 +102,7 @@ export GOOGLE_PUBSUB_TOPIC=php-example-topic # Security Center export GOOGLE_ORGANIZATION_ID= -export GOOGLE_TOPIC_ID= +export GOOGLE_SECURITYCENTER_PUBSUB_TOPIC= # Spanner export GOOGLE_SPANNER_INSTANCE_ID= diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index 0e317cb1a9..c458f428aa 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_TOPIC_ID'); + return self::requireEnv('GOOGLE_SECURITYCENTER_PUBSUB_TOPIC'); } private static function randomNotificationId() From 3423e9ceb80d6e721dcd44c6de203dc09c3de4c2 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:11:58 -0700 Subject: [PATCH 11/27] Added encrypted secrets --- .kokoro/secrets.sh.enc | Bin 7757 -> 7889 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.kokoro/secrets.sh.enc b/.kokoro/secrets.sh.enc index 0bb610715ffef00e2f80d09b729f69c99f13c0a3..e9667901439690f4aaeea2f8ef635c9685a58b14 100644 GIT binary patch literal 7889 zcmV;?9xmYuBmfTBrh1ZgM+AN^&2$D+cFVvZA7i)0qtpq3y-3hoeG8ZI8WN~I0LMxY zs;(D#MsjW}g0{BU8)ky385(qS2;w->e&$uJT9Ep`A_Ok2UolOYG9NselWEYGCZ+^i zl>zX}A-}|F#CZLf$Q{reD76^N8`{A|@`JoWe=hY}F>|t_m5X&D4Xq1jEG0@DS`&Qw zq*-SHZ|%*gH&FZLd=T_o#-vqcnfi|AUm<%!E2&$o`a6JNXzW*Q0tlJXsO#(YY(Xy4 zc{Bs`Y~G`>6S9ohS`kZ95bBzv8<2XXnvpH8xGWnJWsx>t1plya3>kM{N44{i6^h3( zwp5c9#|wUUPtrSL^>PKrg&;SJhYf&EHnPh^pq<^-_x5Qvu9&l7qFg62_a4=ldfef~+><6r{ zfZ>K`v3%PSnau6=%f7*9I}3Us_h*|OP;SOj&@2lVt3f#e)q^yY-(=SlU$tv>Njp)f zO0|9>>(ItrpCYJr{B8f_Mb{kM3Uh&$BLRJNtg&+cr^Mv;Ax=I8*7h3lb#WBjB>pAO zR`mNIR2P=`Ki5ziWV~zvjcqD<^Eh{mg#^hq@-!t9Q7hbjV$lDXIX=uS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JKmM%GjPVhIAS~eS4sQesvmI!0a&%u8tK;4Ou6UaoWl@BGDi* z0!=3*MG)C{g&Wd4q9+%#Q-6879!n+PCB^!akh$4DvJHhdDK)6|fjW;RSb!^0^F!p6 zXJDGrw`8j@h0LN&oiN@3`Od{HK{ZaKrF3QJv$YUQyiv_yA!*D^bl*>RwLf=Xa6y>k zLZ|r4)9;s6Tfz{Pd7oC3Ol!M6981Iuql*%L+x7oQrGVRf9kP}VyFM(+5=uh7y7eeh zKoQaYso4O1c~Z4G{wOKUU9`l6r5J9h$VeJ?GF3oiF`L6ChhDC0xtz*v2i#4_=X0el z`bIVW)MA~Kp9(%(s$mp0%w5QAH|aV@TiO`3!c76J?PFf~<)&7wWPIZ;nsB<93CSLk zSSXX+p+0*}#~i>2#sWSH1FSD)XU!0?)nq`QvubM&ZI8FHG2#G>yPV5Qt>+Oo^+q9KkhKdzbu4N^ zy5R^Pn#mk*mAlsLQDU|dOxnmAR&5kpHw3zf74x-gul62Gtk)*lXi zhkqy3ZTdpmHTj9>aF;!=m*NJy8(H{Zz43G`7fODk#|T#T7gfHLqo-Sp-$5|q(Ohmn TK`sUNuIu&N7QqwOI788|#)|W5 From 4afb37bce98cd5315ca17ecb43aac1806680fd7a Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Fri, 3 Apr 2020 11:27:33 -0700 Subject: [PATCH 12/27] Fixed style problems --- securitycenter/test/SecurityCenterTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index c458f428aa..6b70a16a2f 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -124,4 +124,5 @@ private static function randomNotificationId() { return uniqid('php-notification-config-'); } -} \ No newline at end of file + +} From 1bd50a6e9a66c6492bd454c88693cdc583ee96b5 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Fri, 3 Apr 2020 11:40:02 -0700 Subject: [PATCH 13/27] Ran php-cs-fixer --- securitycenter/src/create_notification.php | 2 +- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/receive_notification.php | 2 +- securitycenter/src/update_notification.php | 2 +- securitycenter/test/SecurityCenterTest.php | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index e815e5e816..26934a6989 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index d6609b36d8..e318c2079e 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 29edc71aa1..4000761e77 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index dd7bc34754..b67e23ab5c 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); } list($_, $organizationId) = $argv; diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index 0ccaefc31c..ddb39bf785 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); + return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 9a51913ff7..0711b0e4c5 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index 6b70a16a2f..d3828a394e 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -124,5 +124,4 @@ private static function randomNotificationId() { return uniqid('php-notification-config-'); } - } From fa78f79cd3f5dcf21fee10b9eb72f24fb165afc6 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 17 Mar 2020 10:34:08 -0700 Subject: [PATCH 14/27] Added PHP code samples for SecurityCenter --- securitycenter/composer.json | 10 ++ securitycenter/phpunit.xml.dist | 42 +++++++ securitycenter/src/create_notification.php | 56 +++++++++ securitycenter/src/delete_notification.php | 45 ++++++++ securitycenter/src/get_notification.php | 44 +++++++ securitycenter/src/list_notification.php | 49 ++++++++ securitycenter/src/receive_notification.php | 45 ++++++++ securitycenter/src/update_notification.php | 61 ++++++++++ securitycenter/test/securitycenterTest.php | 121 ++++++++++++++++++++ 9 files changed, 473 insertions(+) create mode 100644 securitycenter/composer.json create mode 100644 securitycenter/phpunit.xml.dist create mode 100644 securitycenter/src/create_notification.php create mode 100644 securitycenter/src/delete_notification.php create mode 100644 securitycenter/src/get_notification.php create mode 100644 securitycenter/src/list_notification.php create mode 100644 securitycenter/src/receive_notification.php create mode 100644 securitycenter/src/update_notification.php create mode 100644 securitycenter/test/securitycenterTest.php diff --git a/securitycenter/composer.json b/securitycenter/composer.json new file mode 100644 index 0000000000..98d2162bf0 --- /dev/null +++ b/securitycenter/composer.json @@ -0,0 +1,10 @@ +{ + + "require": { + "google/cloud-security-center": "^0.5.0", + "google/cloud-pubsub": "^1.21" + }, + "require-dev": { + "phpunit/phpunit": "^8" + } +} diff --git a/securitycenter/phpunit.xml.dist b/securitycenter/phpunit.xml.dist new file mode 100644 index 0000000000..d59be6c31b --- /dev/null +++ b/securitycenter/phpunit.xml.dist @@ -0,0 +1,42 @@ + + + + + + test + + + + + + + + ./src + + ./vendor + + + + diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php new file mode 100644 index 0000000000..ecc9be48fc --- /dev/null +++ b/securitycenter/src/create_notification.php @@ -0,0 +1,56 @@ +setFilter("state = \"ACTIVE\""); + $notificationConfig = new NotificationConfig(); + $notificationConfig->setDescription("PHP notification config"); + $notificationConfig->setPubsubTopic($pubsubTopic); + $notificationConfig->setStreamingConfig($streamingConfig); + + $response = $securityCenterClient->createNotificationConfig($organizationName, $notificationConfigId, $notificationConfig); + printf("Notification config was created: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_create_notification_config] \ No newline at end of file diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php new file mode 100644 index 0000000000..bb1c290577 --- /dev/null +++ b/securitycenter/src/delete_notification.php @@ -0,0 +1,45 @@ +deleteNotificationConfig($notificationConfigName); + printf("Notification config was deleted"); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_delete_notification_config] \ No newline at end of file diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php new file mode 100644 index 0000000000..9223fb9f51 --- /dev/null +++ b/securitycenter/src/get_notification.php @@ -0,0 +1,44 @@ +getNotificationConfig($notificationConfigName); + printf("Notification config was retrieved: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} +// [END scc_get_notification_config] \ No newline at end of file diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php new file mode 100644 index 0000000000..ee21368cd1 --- /dev/null +++ b/securitycenter/src/list_notification.php @@ -0,0 +1,49 @@ +listNotificationConfigs($organizationName); + $count = 0; + foreach ($pagedResponse->iterateAllElements() as $element) { + $count += 1; + } + + printf("Notification configs were listed"); + return $count; + +} finally { + $securityCenterClient->close(); +} + +// [END scc_list_notification_configs] \ No newline at end of file diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php new file mode 100644 index 0000000000..adfeeb5a46 --- /dev/null +++ b/securitycenter/src/receive_notification.php @@ -0,0 +1,45 @@ +subscription($projectSubscriptionName); + +$pubsub = new PubSubClient([ + 'projectId' => $projectId, +]); + +foreach ($subscription->pull() as $message) { + printf('Message: %s' . PHP_EOL, $message->data()); + // Acknowledge the Pub/Sub message has been received, so it will not be pulled multiple times. + $subscription->acknowledge($message); +} +// [END scc_receive_notifications] \ No newline at end of file diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php new file mode 100644 index 0000000000..76f8b4ea36 --- /dev/null +++ b/securitycenter/src/update_notification.php @@ -0,0 +1,61 @@ +setFilter("state = \"ACTIVE\""); + $notificationConfig = new NotificationConfig(); + $notificationConfig->setName($notificationConfigName); + $notificationConfig->setDescription("Updated description."); + $notificationConfig->setPubsubTopic($pubsubTopic); + $fieldMask = new FieldMask(); + $fieldMask->setPaths(array("description", "pubsub_topic")); + + $response = $securityCenterClient->updateNotificationConfig($notificationConfig, array($fieldMask)); + printf("Notification config was updated: %s", $response->getName()); + +} finally { + $securityCenterClient->close(); +} + +// [END scc_update_notification_config] \ No newline at end of file diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php new file mode 100644 index 0000000000..1235188ef7 --- /dev/null +++ b/securitycenter/test/securitycenterTest.php @@ -0,0 +1,121 @@ +runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-create", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-create", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + } + + public function testGetNotificationConfig() + { + $createOutput = $this->runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $getOutput = $this->runSnippet('get_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + ]); + + $this->assertContains('Notification config was retrieved', $getOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-get", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + + } + + public function testUpdateNotificationConfig() + { + $createOutput = $this->runSnippet('create_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was created', $createOutput); + + $getOutput = $this->runSnippet('update_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + self::getProject(), + self::getTopicName() + ]); + + $this->assertContains('Notification config was updated', $getOutput); + + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + "php-notification-config-update", + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + + } + + public function testListNotificationConfig() + { + $listOutput = $this->runSnippet('list_notification', [ + self::getOrganizationId(), + ]); + + $this->assertContains('Notification configs were listed', $listOutput); + + } + + private static function getOrganizationId() { + return "1081635000895"; + } + + private static function getProject() { + return "project-a-id"; + } + + private static function getTopicName() { + return "notifications-sample-topic"; + } +} \ No newline at end of file From 945b040130cc8a4847a622597ff7f6bb9d44c211 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Mon, 30 Mar 2020 13:19:18 -0700 Subject: [PATCH 15/27] Addressed first comments --- securitycenter/composer.json | 2 - securitycenter/src/create_notification.php | 6 +- securitycenter/src/delete_notification.php | 5 +- securitycenter/src/get_notification.php | 5 +- securitycenter/src/list_notification.php | 3 +- securitycenter/src/receive_notification.php | 5 +- securitycenter/src/update_notification.php | 5 +- securitycenter/test/securitycenterTest.php | 78 +++++++++++---------- 8 files changed, 53 insertions(+), 56 deletions(-) diff --git a/securitycenter/composer.json b/securitycenter/composer.json index 98d2162bf0..6d4a4167cc 100644 --- a/securitycenter/composer.json +++ b/securitycenter/composer.json @@ -1,10 +1,8 @@ { - "require": { "google/cloud-security-center": "^0.5.0", "google/cloud-pubsub": "^1.21" }, "require-dev": { - "phpunit/phpunit": "^8" } } diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index ecc9be48fc..3fee395247 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -17,17 +17,15 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 4) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_create_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use \Google\Cloud\SecurityCenter\V1\NotificationConfig; - /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; // $notificationConfigId = {"your-unique-id"}; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index bb1c290577..1755de1f2f 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_delete_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 9223fb9f51..fc1e90247d 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_get_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index ee21368cd1..317f9ea24f 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -18,12 +18,11 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); + return printf("Usage: php %s ORGANIZATION_ID\n", basename(__FILE__)); } list($_, $organizationId) = $argv; // [START scc_list_notification_configs] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index adfeeb5a46..eddde99ed0 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 2) { + return printf("Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n", basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; // [START scc_receive_notifications] - use Google\Cloud\PubSub\PubSubClient; /** Uncomment and populate these variables in your code */ diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 76f8b4ea36..60ab435c60 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -17,13 +17,12 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; -if (count($argv) < 1) { - return printf("Usage: php %s PROJECT_ID STRING\n", __FILE__); +if (count($argv) < 4) { + return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] - use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use \Google\Cloud\SecurityCenter\V1\NotificationConfig; use \Google\Protobuf\FieldMask; diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php index 1235188ef7..64a44c147e 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/securitycenterTest.php @@ -22,31 +22,47 @@ class securitycenterTest extends TestCase { use TestTrait; + private static $testNotificationCreate; + private static $testNotificationGet; + private static $testNotificationUpdate; + + public static function setUpBeforeClass() + { + self::$testNotificationCreate = self::randomNotificationId(); + self::$testNotificationGet = self::randomNotificationId(); + self::$testNotificationUpdate = self::randomNotificationId(); + } + + private function deleteConfig(string $configId) + { + $deleteOutput = $this->runSnippet('delete_notification', [ + self::getOrganizationId(), + $configId, + ]); + + $this->assertContains('Notification config was deleted', $deleteOutput); + } + public function testCreateNotification() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-create", - self::getProject(), + self::$testNotificationCreate, + self::$projectId, self::getTopicName() ]); $this->assertContains('Notification config was created', $createOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-create", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); + self::deleteConfig(self::$testNotificationCreate); } public function testGetNotificationConfig() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-get", - self::getProject(), + self::$testNotificationGet, + self::$projectId, self::getTopicName() ]); @@ -54,26 +70,20 @@ public function testGetNotificationConfig() $getOutput = $this->runSnippet('get_notification', [ self::getOrganizationId(), - "php-notification-config-get", + self::$testNotificationGet ]); $this->assertContains('Notification config was retrieved', $getOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-get", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); - + self::deleteConfig(self::$testNotificationGet); } public function testUpdateNotificationConfig() { $createOutput = $this->runSnippet('create_notification', [ self::getOrganizationId(), - "php-notification-config-update", - self::getProject(), + self::$testNotificationUpdate, + self::$projectId, self::getTopicName() ]); @@ -81,20 +91,14 @@ public function testUpdateNotificationConfig() $getOutput = $this->runSnippet('update_notification', [ self::getOrganizationId(), - "php-notification-config-update", - self::getProject(), + self::$testNotificationUpdate, + self::$projectId, self::getTopicName() ]); $this->assertContains('Notification config was updated', $getOutput); - $deleteOutput = $this->runSnippet('delete_notification', [ - self::getOrganizationId(), - "php-notification-config-update", - ]); - - $this->assertContains('Notification config was deleted', $deleteOutput); - + self::deleteConfig(self::$testNotificationUpdate); } public function testListNotificationConfig() @@ -104,18 +108,20 @@ public function testListNotificationConfig() ]); $this->assertContains('Notification configs were listed', $listOutput); - } - private static function getOrganizationId() { - return "1081635000895"; + private static function getOrganizationId() + { + return self::requireEnv('GOOGLE_ORGANIZATION_ID'); } - private static function getProject() { - return "project-a-id"; + private static function getTopicName() + { + return self::requireEnv('GOOGLE_TOPIC_ID'); } - private static function getTopicName() { - return "notifications-sample-topic"; + private static function randomNotificationId() + { + return uniqid('php-notification-config-'); } } \ No newline at end of file From 0a9d44708250e4d4eb92c104c58ede327f32005c Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 10:57:13 -0700 Subject: [PATCH 16/27] Removed required dev --- securitycenter/composer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/securitycenter/composer.json b/securitycenter/composer.json index 6d4a4167cc..32fff1ac26 100644 --- a/securitycenter/composer.json +++ b/securitycenter/composer.json @@ -2,7 +2,5 @@ "require": { "google/cloud-security-center": "^0.5.0", "google/cloud-pubsub": "^1.21" - }, - "require-dev": { } } From 21790c9df56f303e6dd66e616deb2ae21feb9809 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 11:00:53 -0700 Subject: [PATCH 17/27] Removed /'s --- securitycenter/src/create_notification.php | 4 ++-- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/update_notification.php | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 3fee395247..0f31124316 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -23,8 +23,8 @@ list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_create_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; -use \Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\NotificationConfig; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 1755de1f2f..6d20a5511f 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_delete_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index fc1e90247d..fc62943079 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId, $notificationConfigId) = $argv; // [START scc_get_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 317f9ea24f..0a23b00371 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -23,7 +23,7 @@ list($_, $organizationId) = $argv; // [START scc_list_notification_configs] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 60ab435c60..7e274548a4 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -23,9 +23,9 @@ list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] -use \Google\Cloud\SecurityCenter\V1\SecurityCenterClient; -use \Google\Cloud\SecurityCenter\V1\NotificationConfig; -use \Google\Protobuf\FieldMask; +use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; +use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Protobuf\FieldMask; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; From ea3c47d0241a6130970700bb1f0e85b692718fe6 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Tue, 31 Mar 2020 13:57:47 -0700 Subject: [PATCH 18/27] Fixed remaining comments --- securitycenter/src/create_notification.php | 38 +++++++------- securitycenter/src/delete_notification.php | 26 +++++----- securitycenter/src/get_notification.php | 25 +++++---- securitycenter/src/list_notification.php | 27 ++++------ securitycenter/src/receive_notification.php | 10 ++-- securitycenter/src/update_notification.php | 56 ++++++++++----------- 6 files changed, 84 insertions(+), 98 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 0f31124316..a8e94ef219 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; @@ -33,22 +33,22 @@ // $topicName = "{your-topic}"; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$pubsubTopic = "projects/" . $projectId . "/topics/" . $topicName; - -try { - $streamingConfig = new NotificationConfig\StreamingConfig(); - $streamingConfig->setFilter("state = \"ACTIVE\""); - $notificationConfig = new NotificationConfig(); - $notificationConfig->setDescription("PHP notification config"); - $notificationConfig->setPubsubTopic($pubsubTopic); - $notificationConfig->setStreamingConfig($streamingConfig); - - $response = $securityCenterClient->createNotificationConfig($organizationName, $notificationConfigId, $notificationConfig); - printf("Notification config was created: %s", $response->getName()); - -} finally { - $securityCenterClient->close(); -} - +$organizationName = $securityCenterClient::organizationName($organizationId); +$pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); + +$streamingConfig = new NotificationConfig\StreamingConfig(); +$streamingConfig->setFilter("state = \"ACTIVE\""); +$notificationConfig = new NotificationConfig(); +$notificationConfig->setDescription('A sample notification config'); +$notificationConfig->setPubsubTopic($pubsubTopic); +$notificationConfig->setStreamingConfig($streamingConfig); + +$response = $securityCenterClient->createNotificationConfig( + $organizationName, + $notificationConfigId, + $notificationConfig +); +printf('Notification config was created: %s', $response->getName()); + +$securityCenterClient->close(); // [END scc_create_notification_config] \ No newline at end of file diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 6d20a5511f..9ba31782df 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; @@ -26,19 +26,17 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; +$notificationConfigName = $securityCenterClient::notificationConfigName( + $organizationId, + $notificationConfigId +); -try { - $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); - printf("Notification config was deleted"); - -} finally { - $securityCenterClient->close(); -} +$response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); +print('Notification config was deleted'); +$securityCenterClient->close(); // [END scc_delete_notification_config] \ No newline at end of file diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index fc62943079..155c142c61 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; @@ -26,18 +26,17 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; +$notificationConfigName = $securityCenterClient::notificationConfigName( + $organizationId, + $notificationConfigId +); -try { - $response = $securityCenterClient->getNotificationConfig($notificationConfigName); - printf("Notification config was retrieved: %s", $response->getName()); +$response = $securityCenterClient->getNotificationConfig($notificationConfigName); +printf('Notification config was retrieved: %s', $response->getName()); -} finally { - $securityCenterClient->close(); -} +$securityCenterClient->close(); // [END scc_get_notification_config] \ No newline at end of file diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 0a23b00371..91f138cc1d 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf("Usage: php %s ORGANIZATION_ID\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); } list($_, $organizationId) = $argv; @@ -26,23 +26,16 @@ use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; +// $organizationId = '{your-org-id}'; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; +$organizationName = $securityCenterClient::organizationName($organizationId); -try { - $pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); - $count = 0; - foreach ($pagedResponse->iterateAllElements() as $element) { - $count += 1; - } - - printf("Notification configs were listed"); - return $count; - -} finally { - $securityCenterClient->close(); +$pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); +foreach ($pagedResponse->iterateAllElements() as $element) { + printf('Found notification config %s', $element->getName()); } +print('Notification configs were listed'); +$securityCenterClient->close(); // [END scc_list_notification_configs] \ No newline at end of file diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index eddde99ed0..b0a26c6182 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf("Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n", basename(__FILE__)); + return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; @@ -26,15 +26,13 @@ use Google\Cloud\PubSub\PubSubClient; /** Uncomment and populate these variables in your code */ -// String projectId = "{your-project}"; -// String subscriptionId = "{your-subscription}"; - -$projectSubscriptionName = "projects/" . $projectId . "/subscriptions/" . $subscriptionId; -$subscription = $pubsub->subscription($projectSubscriptionName); +// $projectId = "{your-project-id}"; +// $subscriptionId = "{your-subscription-id}"; $pubsub = new PubSubClient([ 'projectId' => $projectId, ]); +$subscription = $pubsub->subscription($subscriptionId); foreach ($subscription->pull() as $message) { printf('Message: %s' . PHP_EOL, $message->data()); diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 7e274548a4..e7efb5c87a 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -2,14 +2,14 @@ /** * Copyright 2020 Google LLC. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -18,43 +18,41 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf("Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n", basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; // [START scc_update_notification_config] use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\NotificationConfig\StreamingConfig; use Google\Protobuf\FieldMask; /** Uncomment and populate these variables in your code */ -// $organizationId = "{your-org-id}"; -// $notificationConfigId = {"your-unique-id"}; -// $projectId = "{your-project}""; -// $topicName = "{your-topic}"; +// $organizationId = '{your-org-id}'; +// $notificationConfigId = {'your-unique-id'}; +// $projectId = '{your-project}'; +// $topicName = '{your-topic}'; $securityCenterClient = new SecurityCenterClient(); -$organizationName = "organizations/" . $organizationId; - -// Ensure this ServiceAccount has the "pubsub.topics.setIamPolicy" permission on the topic. -$pubsubTopic = "projects/" . $projectId . "/topics/" . $topicName; -$notificationConfigName = $organizationName . "/notificationConfigs/" . $notificationConfigId; - -try { - $streamingConfig = new NotificationConfig\StreamingConfig(); - $streamingConfig->setFilter("state = \"ACTIVE\""); - $notificationConfig = new NotificationConfig(); - $notificationConfig->setName($notificationConfigName); - $notificationConfig->setDescription("Updated description."); - $notificationConfig->setPubsubTopic($pubsubTopic); - $fieldMask = new FieldMask(); - $fieldMask->setPaths(array("description", "pubsub_topic")); - - $response = $securityCenterClient->updateNotificationConfig($notificationConfig, array($fieldMask)); - printf("Notification config was updated: %s", $response->getName()); - -} finally { - $securityCenterClient->close(); -} +// Ensure this ServiceAccount has the 'pubsub.topics.setIamPolicy' permission on the topic. +// https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/setIamPolicy +$pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); +$notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); + +$streamingConfig = new StreamingConfig(); +$streamingConfig->setFilter("state = \"ACTIVE\""); +$fieldMask = new FieldMask(); +$fieldMask->setPaths(['description', 'pubsub_topic']); +$notificationConfig = new NotificationConfig(); +$notificationConfig + ->setName($notificationConfigName) + ->setDescription('Updated description.') + ->setPubsubTopic($pubsubTopic); + +$response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); +printf('Notification config was updated: %s', $response->getName()); + +$securityCenterClient->close(); // [END scc_update_notification_config] \ No newline at end of file From 68295090b9fde231aabd3d140ff760c7fb92017e Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 13:49:05 -0700 Subject: [PATCH 19/27] Addressed remaining comments --- .kokoro/secrets-example.sh | 4 ++++ securitycenter/src/create_notification.php | 14 +++++++------- securitycenter/src/delete_notification.php | 3 +-- securitycenter/src/get_notification.php | 3 +-- securitycenter/src/list_notification.php | 9 ++++----- securitycenter/src/receive_notification.php | 3 ++- securitycenter/src/update_notification.php | 6 ++---- securitycenter/test/securitycenterTest.php | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 88710d0c69..6db7d34bea 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -100,6 +100,10 @@ export REDIS_PORT= export GOOGLE_PUBSUB_SUBSCRIPTION=php-example-subscription export GOOGLE_PUBSUB_TOPIC=php-example-topic +# Security Center +export GOOGLE_ORGANIZATION_ID= +export GOOGLE_PUBSUB_TOPIC=php-example-topic + # Spanner export GOOGLE_SPANNER_INSTANCE_ID= export GOOGLE_SPANNER_DATABASE_ID=test-database diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index a8e94ef219..ee310b5a5e 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -25,6 +25,7 @@ // [START scc_create_notification_config] use Google\Cloud\SecurityCenter\V1\SecurityCenterClient; use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\NotificationConfig\StreamingConfig; /** Uncomment and populate these variables in your code */ // $organizationId = "{your-org-id}"; @@ -36,12 +37,12 @@ $organizationName = $securityCenterClient::organizationName($organizationId); $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); -$streamingConfig = new NotificationConfig\StreamingConfig(); +$streamingConfig = new StreamingConfig(); $streamingConfig->setFilter("state = \"ACTIVE\""); -$notificationConfig = new NotificationConfig(); -$notificationConfig->setDescription('A sample notification config'); -$notificationConfig->setPubsubTopic($pubsubTopic); -$notificationConfig->setStreamingConfig($streamingConfig); +$notificationConfig = (new NotificationConfig()) + ->setDescription('A sample notification config') + ->setPubsubTopic($pubsubTopic) + ->setStreamingConfig($streamingConfig); $response = $securityCenterClient->createNotificationConfig( $organizationName, @@ -50,5 +51,4 @@ ); printf('Notification config was created: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_create_notification_config] \ No newline at end of file +// [END scc_create_notification_config] diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 9ba31782df..1c94f66c10 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -38,5 +38,4 @@ $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); print('Notification config was deleted'); -$securityCenterClient->close(); -// [END scc_delete_notification_config] \ No newline at end of file +// [END scc_delete_notification_config] diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 155c142c61..814abd1fcf 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -38,5 +38,4 @@ $response = $securityCenterClient->getNotificationConfig($notificationConfigName); printf('Notification config was retrieved: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_get_notification_config] \ No newline at end of file +// [END scc_get_notification_config] diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 91f138cc1d..666d091505 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -31,11 +31,10 @@ $securityCenterClient = new SecurityCenterClient(); $organizationName = $securityCenterClient::organizationName($organizationId); -$pagedResponse = $securityCenterClient->listNotificationConfigs($organizationName); -foreach ($pagedResponse->iterateAllElements() as $element) { - printf('Found notification config %s', $element->getName()); +foreach ($securityCenterClient->listNotificationConfigs($organizationName) as $element) { + printf('Found notification config %s' . PHP_EOL, $element->getName()); } print('Notification configs were listed'); -$securityCenterClient->close(); -// [END scc_list_notification_configs] \ No newline at end of file + +// [END scc_list_notification_configs] diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index b0a26c6182..0ccaefc31c 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -39,4 +39,5 @@ // Acknowledge the Pub/Sub message has been received, so it will not be pulled multiple times. $subscription->acknowledge($message); } -// [END scc_receive_notifications] \ No newline at end of file + +// [END scc_receive_notifications] diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index e7efb5c87a..8106561f89 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -45,8 +45,7 @@ $streamingConfig->setFilter("state = \"ACTIVE\""); $fieldMask = new FieldMask(); $fieldMask->setPaths(['description', 'pubsub_topic']); -$notificationConfig = new NotificationConfig(); -$notificationConfig +$notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') ->setPubsubTopic($pubsubTopic); @@ -54,5 +53,4 @@ $response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); printf('Notification config was updated: %s', $response->getName()); -$securityCenterClient->close(); -// [END scc_update_notification_config] \ No newline at end of file +// [END scc_update_notification_config] diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/securitycenterTest.php index 64a44c147e..5d35dd52cd 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/securitycenterTest.php @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_TOPIC_ID'); + return self::requireEnv('GOOGLE_PUBSUB_TOPIC'); } private static function randomNotificationId() From e191a8915aaa6c84e46774b48c59ef8ac8589a28 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 14:05:26 -0700 Subject: [PATCH 20/27] Added fluent setters --- securitycenter/src/create_notification.php | 3 +-- securitycenter/src/update_notification.php | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index ee310b5a5e..9f7ac0771a 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -37,8 +37,7 @@ $organizationName = $securityCenterClient::organizationName($organizationId); $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); -$streamingConfig = new StreamingConfig(); -$streamingConfig->setFilter("state = \"ACTIVE\""); +$streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); $notificationConfig = (new NotificationConfig()) ->setDescription('A sample notification config') ->setPubsubTopic($pubsubTopic) diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 8106561f89..37c1dbca89 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -41,10 +41,8 @@ $pubsubTopic = $securityCenterClient::topicName($projectId, $topicName); $notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); -$streamingConfig = new StreamingConfig(); -$streamingConfig->setFilter("state = \"ACTIVE\""); -$fieldMask = new FieldMask(); -$fieldMask->setPaths(['description', 'pubsub_topic']); +$streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); +$fieldMask = (new FieldMask())>setPaths(['description', 'pubsub_topic']); $notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') From 2ef5a4e8f793574c2fd54245475077a4bc0368ea Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Wed, 1 Apr 2020 14:20:22 -0700 Subject: [PATCH 21/27] Fixed typo --- securitycenter/src/update_notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 37c1dbca89..30f367b0df 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -42,7 +42,7 @@ $notificationConfigName = $securityCenterClient::notificationConfigName($organizationId, $notificationConfigId); $streamingConfig = (new StreamingConfig())->setFilter("state = \"ACTIVE\""); -$fieldMask = (new FieldMask())>setPaths(['description', 'pubsub_topic']); +$fieldMask = (new FieldMask())->setPaths(['description', 'pubsub_topic']); $notificationConfig = (new NotificationConfig()) ->setName($notificationConfigName) ->setDescription('Updated description.') From 46029b661aee8aee4a65787d8f03827eb826179c Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:01:08 -0700 Subject: [PATCH 22/27] Addressed environment variable and EOL changes --- .kokoro/secrets-example.sh | 2 +- securitycenter/src/create_notification.php | 2 +- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/update_notification.php | 2 +- .../test/{securitycenterTest.php => SecurityCenterTest.php} | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) rename securitycenter/test/{securitycenterTest.php => SecurityCenterTest.php} (97%) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 6db7d34bea..3a42a7da33 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -102,7 +102,7 @@ export GOOGLE_PUBSUB_TOPIC=php-example-topic # Security Center export GOOGLE_ORGANIZATION_ID= -export GOOGLE_PUBSUB_TOPIC=php-example-topic +export GOOGLE_TOPIC_ID= # Spanner export GOOGLE_SPANNER_INSTANCE_ID= diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index 9f7ac0771a..e815e5e816 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -48,6 +48,6 @@ $notificationConfigId, $notificationConfig ); -printf('Notification config was created: %s', $response->getName()); +printf('Notification config was created: %s' . PHP_EOL, $response->getName()); // [END scc_create_notification_config] diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index 1c94f66c10..d6609b36d8 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -36,6 +36,6 @@ ); $response = $securityCenterClient->deleteNotificationConfig($notificationConfigName); -print('Notification config was deleted'); +print('Notification config was deleted' . PHP_EOL); // [END scc_delete_notification_config] diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 814abd1fcf..29edc71aa1 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -36,6 +36,6 @@ ); $response = $securityCenterClient->getNotificationConfig($notificationConfigName); -printf('Notification config was retrieved: %s', $response->getName()); +printf('Notification config was retrieved: %s' . PHP_EOL, $response->getName()); // [END scc_get_notification_config] diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index 666d091505..dd7bc34754 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -35,6 +35,6 @@ printf('Found notification config %s' . PHP_EOL, $element->getName()); } -print('Notification configs were listed'); +print('Notification configs were listed' . PHP_EOL); // [END scc_list_notification_configs] diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 30f367b0df..9a51913ff7 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -49,6 +49,6 @@ ->setPubsubTopic($pubsubTopic); $response = $securityCenterClient->updateNotificationConfig($notificationConfig, [$fieldMask]); -printf('Notification config was updated: %s', $response->getName()); +printf('Notification config was updated: %s' . PHP_EOL, $response->getName()); // [END scc_update_notification_config] diff --git a/securitycenter/test/securitycenterTest.php b/securitycenter/test/SecurityCenterTest.php similarity index 97% rename from securitycenter/test/securitycenterTest.php rename to securitycenter/test/SecurityCenterTest.php index 5d35dd52cd..0e317cb1a9 100644 --- a/securitycenter/test/securitycenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -18,7 +18,7 @@ use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; -class securitycenterTest extends TestCase +class securityCenterTest extends TestCase { use TestTrait; @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_PUBSUB_TOPIC'); + return self::requireEnv('GOOGLE_TOPIC_ID'); } private static function randomNotificationId() From 15c130d5156dbf8df1af891bc956eeec22206dc1 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:01:52 -0700 Subject: [PATCH 23/27] Changed pubsub topic name --- .kokoro/secrets-example.sh | 2 +- securitycenter/test/SecurityCenterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/secrets-example.sh b/.kokoro/secrets-example.sh index 3a42a7da33..287eb010cc 100644 --- a/.kokoro/secrets-example.sh +++ b/.kokoro/secrets-example.sh @@ -102,7 +102,7 @@ export GOOGLE_PUBSUB_TOPIC=php-example-topic # Security Center export GOOGLE_ORGANIZATION_ID= -export GOOGLE_TOPIC_ID= +export GOOGLE_SECURITYCENTER_PUBSUB_TOPIC= # Spanner export GOOGLE_SPANNER_INSTANCE_ID= diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index 0e317cb1a9..c458f428aa 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -117,7 +117,7 @@ private static function getOrganizationId() private static function getTopicName() { - return self::requireEnv('GOOGLE_TOPIC_ID'); + return self::requireEnv('GOOGLE_SECURITYCENTER_PUBSUB_TOPIC'); } private static function randomNotificationId() From 0940ce37b2471f5bc63dc4aca5df12e2cdecaa66 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Thu, 2 Apr 2020 11:11:58 -0700 Subject: [PATCH 24/27] Added encrypted secrets --- .kokoro/secrets.sh.enc | Bin 7757 -> 7889 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.kokoro/secrets.sh.enc b/.kokoro/secrets.sh.enc index 0bb610715ffef00e2f80d09b729f69c99f13c0a3..e9667901439690f4aaeea2f8ef635c9685a58b14 100644 GIT binary patch literal 7889 zcmV;?9xmYuBmfTBrh1ZgM+AN^&2$D+cFVvZA7i)0qtpq3y-3hoeG8ZI8WN~I0LMxY zs;(D#MsjW}g0{BU8)ky385(qS2;w->e&$uJT9Ep`A_Ok2UolOYG9NselWEYGCZ+^i zl>zX}A-}|F#CZLf$Q{reD76^N8`{A|@`JoWe=hY}F>|t_m5X&D4Xq1jEG0@DS`&Qw zq*-SHZ|%*gH&FZLd=T_o#-vqcnfi|AUm<%!E2&$o`a6JNXzW*Q0tlJXsO#(YY(Xy4 zc{Bs`Y~G`>6S9ohS`kZ95bBzv8<2XXnvpH8xGWnJWsx>t1plya3>kM{N44{i6^h3( zwp5c9#|wUUPtrSL^>PKrg&;SJhYf&EHnPh^pq<^-_x5Qvu9&l7qFg62_a4=ldfef~+><6r{ zfZ>K`v3%PSnau6=%f7*9I}3Us_h*|OP;SOj&@2lVt3f#e)q^yY-(=SlU$tv>Njp)f zO0|9>>(ItrpCYJr{B8f_Mb{kM3Uh&$BLRJNtg&+cr^Mv;Ax=I8*7h3lb#WB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=A&Y| zEeNcV_PV|jtevsTo&<`l3(xl9e%Y{}}aR}-C+9P4a zl?nw7(g$}Nlnan%FJKmM%GjPVhIAS~eS4sQesvmI!0a&%u8tK;4Ou6UaoWl@BGDi* z0!=3*MG)C{g&Wd4q9+%#Q-6879!n+PCB^!akh$4DvJHhdDK)6|fjW;RSb!^0^F!p6 zXJDGrw`8j@h0LN&oiN@3`Od{HK{ZaKrF3QJv$YUQyiv_yA!*D^bl*>RwLf=Xa6y>k zLZ|r4)9;s6Tfz{Pd7oC3Ol!M6981Iuql*%L+x7oQrGVRf9kP}VyFM(+5=uh7y7eeh zKoQaYso4O1c~Z4G{wOKUU9`l6r5J9h$VeJ?GF3oiF`L6ChhDC0xtz*v2i#4_=X0el z`bIVW)MA~Kp9(%(s$mp0%w5QAH|aV@TiO`3!c76J?PFf~<)&7wWPIZ;nsB<93CSLk zSSXX+p+0*}#~i>2#sWSH1FSD)XU!0?)nq`QvubM&ZI8FHG2#G>yPV5Qt>+Oo^+q9KkhKdzbu4N^ zy5R^Pn#mk*mAlsLQDU|dOxnmAR&5kpHw3zf74x-gul62Gtk)*lXi zhkqy3ZTdpmHTj9>aF;!=m*NJy8(H{Zz43G`7fODk#|T#T7gfHLqo-Sp-$5|q(Ohmn TK`sUNuIu&N7QqwOI788|#)|W5 From 83ad78a8faf2358b42f773ba5b67ab1e48f85a4c Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Fri, 3 Apr 2020 11:27:33 -0700 Subject: [PATCH 25/27] Fixed style problems --- securitycenter/test/SecurityCenterTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index c458f428aa..6b70a16a2f 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -124,4 +124,5 @@ private static function randomNotificationId() { return uniqid('php-notification-config-'); } -} \ No newline at end of file + +} From 6a685383593b318b3115c57aba9034408bc8217e Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Fri, 3 Apr 2020 11:40:02 -0700 Subject: [PATCH 26/27] Ran php-cs-fixer --- securitycenter/src/create_notification.php | 2 +- securitycenter/src/delete_notification.php | 2 +- securitycenter/src/get_notification.php | 2 +- securitycenter/src/list_notification.php | 2 +- securitycenter/src/receive_notification.php | 2 +- securitycenter/src/update_notification.php | 2 +- securitycenter/test/SecurityCenterTest.php | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/securitycenter/src/create_notification.php b/securitycenter/src/create_notification.php index e815e5e816..26934a6989 100644 --- a/securitycenter/src/create_notification.php +++ b/securitycenter/src/create_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; diff --git a/securitycenter/src/delete_notification.php b/securitycenter/src/delete_notification.php index d6609b36d8..e318c2079e 100644 --- a/securitycenter/src/delete_notification.php +++ b/securitycenter/src/delete_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; diff --git a/securitycenter/src/get_notification.php b/securitycenter/src/get_notification.php index 29edc71aa1..4000761e77 100644 --- a/securitycenter/src/get_notification.php +++ b/securitycenter/src/get_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId) = $argv; diff --git a/securitycenter/src/list_notification.php b/securitycenter/src/list_notification.php index dd7bc34754..b67e23ab5c 100644 --- a/securitycenter/src/list_notification.php +++ b/securitycenter/src/list_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 1) { - return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID\n', basename(__FILE__)); } list($_, $organizationId) = $argv; diff --git a/securitycenter/src/receive_notification.php b/securitycenter/src/receive_notification.php index 0ccaefc31c..ddb39bf785 100644 --- a/securitycenter/src/receive_notification.php +++ b/securitycenter/src/receive_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 2) { - return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); + return printf('Usage: php %s PROJECT_ID SUSBSCRIPTION_ID\n', basename(__FILE__)); } list($_, $projectId, $subscriptionId) = $argv; diff --git a/securitycenter/src/update_notification.php b/securitycenter/src/update_notification.php index 9a51913ff7..0711b0e4c5 100644 --- a/securitycenter/src/update_notification.php +++ b/securitycenter/src/update_notification.php @@ -18,7 +18,7 @@ // Include Google Cloud dependendencies using Composer require_once __DIR__ . '/../vendor/autoload.php'; if (count($argv) < 4) { - return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); + return printf('Usage: php %s ORGANIZATION_ID NOTIFICATION_ID PROJECT_ID TOPIC_NAME\n', basename(__FILE__)); } list($_, $organizationId, $notificationConfigId, $projectId, $topicName) = $argv; diff --git a/securitycenter/test/SecurityCenterTest.php b/securitycenter/test/SecurityCenterTest.php index 6b70a16a2f..d3828a394e 100644 --- a/securitycenter/test/SecurityCenterTest.php +++ b/securitycenter/test/SecurityCenterTest.php @@ -124,5 +124,4 @@ private static function randomNotificationId() { return uniqid('php-notification-config-'); } - } From 842f8ed23e94d8b14f04961a7d6db4e8afcd7931 Mon Sep 17 00:00:00 2001 From: Patrick Glinsman Date: Fri, 3 Apr 2020 12:04:05 -0700 Subject: [PATCH 27/27] Remove whitespace after db->drop --- spanner/test/spannerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/spanner/test/spannerTest.php b/spanner/test/spannerTest.php index d36f8f695a..fd166a9ecd 100644 --- a/spanner/test/spannerTest.php +++ b/spanner/test/spannerTest.php @@ -791,7 +791,6 @@ public static function tearDownAfterClass() if (strstr($db->name(), self::$databaseId) !== false) { try { $db->drop(); - } catch (\Exception $e) { $exceptions[] = $e; }