summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/drop_collection.cpp
diff options
context:
space:
mode:
authorVarun Ravichandran <varun.ravichandran@mongodb.com>2021-01-23 00:31:27 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-03 17:03:23 +0000
commit952042b7e54148c3b9875ba5aa31a6a2adaf3af9 (patch)
treeee0901002e9adb92db287e33cb4f1143c35195fb /src/mongo/db/catalog/drop_collection.cpp
parent780295a9322938abbb1c5f9abbb2b22a4f707357 (diff)
downloadmongo-952042b7e54148c3b9875ba5aa31a6a2adaf3af9.tar.gz
SERVER-50993: Audit dropCollection for views
Diffstat (limited to 'src/mongo/db/catalog/drop_collection.cpp')
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 80584fb0e6d..fbcd3b19919 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/catalog/drop_collection.h"
+#include "mongo/db/audit.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/uncommitted_collections.h"
#include "mongo/db/client.h"
@@ -74,12 +75,16 @@ Status _dropView(OperationContext* opCtx,
DropReply* reply,
bool clearBucketCatalog = false) {
if (!db) {
- return Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code());
+ return status;
}
auto view =
ViewCatalog::get(db)->lookupWithoutValidatingDurableViews(opCtx, collectionName.ns());
if (!view) {
- return Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code());
+ return status;
}
// Validates the view or throws an "invalid view" error.
@@ -110,6 +115,10 @@ Status _dropView(OperationContext* opCtx,
}
WriteUnitOfWork wunit(opCtx);
+
+ audit::logDropView(
+ &cc(), collectionName.ns(), view->viewOn().ns(), view->pipeline(), ErrorCodes::OK);
+
Status status = db->dropView(opCtx, collectionName);
if (!status.isOK()) {
return status;
@@ -325,7 +334,9 @@ Status dropCollection(OperationContext* opCtx,
auto view = ViewCatalog::get(db)->lookupWithoutValidatingDurableViews(
opCtx, collectionName.ns());
if (!view) {
- return Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ Status status = Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ audit::logDropView(&cc(), collectionName.ns(), "", {}, status.code());
+ return status;
}
if (!view->timeseries()) {