mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00

* Added caching to EF implementation. Added error handling and logging * Refactored update method to use sqlbulkcopy instead of performing a round trip for each new insert * Initial implementation for quartz job to get list of phishing domains * Updated phishing domain settings to be its own interface * Add phishing domain detection with checksum-based updates
61 lines
1.2 KiB
Transact-SQL
61 lines
1.2 KiB
Transact-SQL
-- Update PhishingDomain table to use Checksum instead of dates
|
|
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'PhishingDomain' AND COLUMN_NAME = 'CreationDate')
|
|
BEGIN
|
|
-- Add Checksum column
|
|
ALTER TABLE [dbo].[PhishingDomain]
|
|
ADD [Checksum] NVARCHAR(64) NULL;
|
|
|
|
-- Drop old columns
|
|
ALTER TABLE [dbo].[PhishingDomain]
|
|
DROP COLUMN [CreationDate], [RevisionDate];
|
|
END
|
|
GO
|
|
|
|
-- Update PhishingDomain_Create stored procedure
|
|
IF OBJECT_ID('[dbo].[PhishingDomain_Create]') IS NOT NULL
|
|
BEGIN
|
|
DROP PROCEDURE [dbo].[PhishingDomain_Create]
|
|
END
|
|
GO
|
|
|
|
CREATE PROCEDURE [dbo].[PhishingDomain_Create]
|
|
@Id UNIQUEIDENTIFIER,
|
|
@Domain NVARCHAR(255),
|
|
@Checksum NVARCHAR(64)
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
INSERT INTO [dbo].[PhishingDomain]
|
|
(
|
|
[Id],
|
|
[Domain],
|
|
[Checksum]
|
|
)
|
|
VALUES
|
|
(
|
|
@Id,
|
|
@Domain,
|
|
@Checksum
|
|
)
|
|
END
|
|
GO
|
|
|
|
-- Create PhishingDomain_ReadChecksum stored procedure
|
|
IF OBJECT_ID('[dbo].[PhishingDomain_ReadChecksum]') IS NOT NULL
|
|
BEGIN
|
|
DROP PROCEDURE [dbo].[PhishingDomain_ReadChecksum]
|
|
END
|
|
GO
|
|
|
|
CREATE PROCEDURE [dbo].[PhishingDomain_ReadChecksum]
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
SELECT TOP 1
|
|
[Checksum]
|
|
FROM
|
|
[dbo].[PhishingDomain]
|
|
END
|
|
GO |