Skip to content

Commit 66626c4

Browse files
author
ludovicferre
committed
Releasing verions 12 now for testing!
Currently tested only against 8.1, but 8.0 should follow real soon.
1 parent bd7ab81 commit 66626c4

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

Constant.cs

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace Symantec.CWoC
66
{
77
class Constant
88
{
9-
public const string VERSION = "11";
10-
public const string ZERODAY_SCHEMA_VERSION = "0003";
9+
public const string VERSION = "12";
10+
public const string ZERODAY_SCHEMA_VERSION = "0004";
1111

1212
#region SQL STRINGS
1313
public const string PATCH_EXCLUSION_QUERY = @"if exists (select 1 from sys.objects where name = 'patchautomation_excluded') select bulletin from patchautomation_excluded";
@@ -218,7 +218,6 @@ Display this help message.
218218
CREATE PROCEDURE [ZeroDayPatch_GetVulnerableMachines-" + ZERODAY_SCHEMA_VERSION + @"]
219219
AS
220220
BEGIN
221-
222221
SELECT LOWER(SUBSTRING( sts.StringRef, 10, 100 )) AS [RefName], sts.[String]
223222
INTO #tmpSeverityString
224223
FROM (
@@ -236,12 +235,10 @@ JOIN [dbo].[String] sts
236235
ON sts.[BaseGuid] = ref.[BaseGuid]
237236
AND sts.[StringRef] = ref.[StringRef]
238237
AND sts.[Culture] = fnc.[Culture]
239-
238+
240239
SELECT swb._ResourceGuid, swb.FirstReleaseDate AS [Released], ISNULL( tss.[String], srl.SeverityName ) AS [Severity]
241240
INTO #tmpBulletinNames
242241
FROM Inv_Software_Bulletin swb
243-
JOIN ItemActive asb
244-
ON asb.Guid = swb._ResourceGuid
245242
JOIN Inv_PM_Severity_Rating sr
246243
ON sr._ResourceGuid = swb._ResourceGuid
247244
AND sr.SeverityRatingSystemGuid <> '6CCEF81F-F791-4DC4-8FC6-90D149FC0187'
@@ -251,37 +248,44 @@ JOIN Inv_Severity_Rating_Level srl
251248
LEFT JOIN #tmpSeverityString tss
252249
ON tss.RefName = LOWER(srl.SeverityName)
253250
254-
255251
SELECT cid._ResourceGuid
256252
INTO #tempScopedResources
257253
FROM Inv_AeX_AC_Identification cid
258254
LEFT JOIN vPMCore_GetAllRetiredMachines ret
259255
ON ret.Guid = cid._ResourceGuid
256+
JOIN Inv_AeX_AC_Client_Agent a
257+
ON a._ResourceGuid = cid._ResourceGuid
258+
AND a.[Agent Name] = 'Altiris Software Update Agent'
259+
AND (dbo.fnVersionCompare(a.[Product Version], '8.0.1000') >= 0)
260260
WHERE ret.Guid IS NULL -- exclude the retired machine
261261
262-
SELECT cb1.BulletinGuid, COUNT(cb1._ResourceGuid)AS Applicable, SUM(cb1.Installed) AS Installed
262+
SELECT cb1.BulletinGuid, COUNT(cb1._ResourceGuid) AS Applicable, SUM(cb1.Installed) AS Installed
263263
INTO #tmpBulletinCnt
264264
FROM (
265-
SELECT bul._ResourceGuid AS [BulletinGuid], sua._ResourceGuid, CASE WHEN COUNT(sua.UpdateGuid) = SUM( CASE WHEN sui.UpdateGuid IS NULL THEN 0 ELSE 1 END ) THEN 1 ELSE 0 END AS [Installed]
266-
FROM vPMWindows_UpdateApplicable sua
267-
JOIN ResourceAssociation b2u
268-
ON b2u.ChildResourceGuid = sua.UpdateGuid
269-
AND b2u.ResourceAssociationTypeGuid = '7EEAB03A-839C-458D-9AF2-55DB6B173293' -- SWB to SWU
270-
JOIN #tmpBulletinNames bul ON bul._ResourceGuid = b2u.ParentResourceGuid
271-
JOIN #tempScopedResources res ON res._ResourceGuid = sua._ResourceGuid
272-
LEFT JOIN vPMWindows_UpdateInstalled sui ON sui.UpdateGuid = sua.UpdateGuid
273-
AND sui._ResourceGuid = sua._ResourceGuid
274-
WHERE sua.UpdateGuid NOT IN -- filter out supersede applicable updates
275-
(
276-
SELECT DISTINCT ChildResourceGuid
277-
FROM ResourceAssociation
278-
WHERE ResourceAssociationTypeGuid = '644A995E-211A-4D94-AA8A-788413B7BE5D'
279-
)
280-
GROUP BY bul._ResourceGuid, sua._ResourceGuid
265+
SELECT bul._ResourceGuid AS [BulletinGuid],
266+
sua._ResourceGuid,
267+
CASE WHEN COUNT(sua.SoftwareUpdateGuid) = SUM( CASE WHEN sus.DistributionStatus IS NULL AND sui.SoftwareUpdateGuid IS NOT NULL THEN 1
268+
WHEN sus.DistributionStatus = 128 THEN 1 -- STATE_INSTALLED
269+
WHEN sus.DistributionStatus = 256 THEN 1 -- STATE_INSTALLED_SUA
270+
WHEN sus.DistributionStatus = 131072 THEN 1 -- STATE_INSTALLED_WITH_ERRORS
271+
-- WHEN sus.DistributionStatus = 8192 THEN 1 -- STATE_SUPERSEDED
272+
ELSE 0 END )
273+
THEN 1
274+
ELSE 0 END AS [Installed]
275+
FROM Inv_Applicable_Windows_Software_Update sua
276+
JOIN ResourceAssociation b2u ON b2u.ChildResourceGuid = sua.SoftwareUpdateGuid
277+
AND b2u.ResourceAssociationTypeGuid = '7EEAB03A-839C-458D-9AF2-55DB6B173293' -- SWB to SWU
278+
JOIN #tmpBulletinNames bul ON bul._ResourceGuid = b2u.ParentResourceGuid
279+
JOIN #tempScopedResources res ON res._ResourceGuid = sua._ResourceGuid
280+
LEFT JOIN Inv_Installed_Windows_Software_Update sui ON sui.SoftwareUpdateGuid = sua.SoftwareUpdateGuid
281+
AND sui._ResourceGuid = sua._ResourceGuid
282+
LEFT JOIN Inv_Software_Update_Distribution_Status sus ON sus._ResourceGuid = sua._ResourceGuid and sus.SoftwareUpdateGuid = sua.SoftwareUpdateGuid
283+
LEFT JOIN ResourceAssociation supersede ON supersede.ChildResourceGuid = sua.SoftwareUpdateGuid and supersede.ResourceAssociationTypeGuid = '644A995E-211A-4D94-AA8A-788413B7BE5D'
284+
WHERE supersede.ParentResourceGuid IS NULL -- filter out supersede applicable updates
285+
GROUP BY bul._ResourceGuid, sua._ResourceGuid
281286
) AS cb1
282287
GROUP BY cb1.BulletinGuid
283288
284-
285289
SELECT distinct(swb._ResourceGuid) AS [_ResourceGuid],
286290
it.Name AS [Bulletin],
287291
swb.Severity AS [Severity],
@@ -303,6 +307,7 @@ DROP TABLE #tmpBulletinNames
303307
DROP TABLE #tmpBulletinCnt
304308
DROP TABLE #tmpSeverityString
305309
DROP TABLE #tempScopedResources
310+
306311
END
307312
";
308313
#endregion

0 commit comments

Comments
 (0)