@@ -3771,6 +3771,58 @@ static void SysOsVersionMajor(EvalContext *ctx)
3771
3771
free (flavor );
3772
3772
}
3773
3773
3774
+ /*****************************************************************************/
3775
+
3776
+ static const char * OSReleaseGet (EvalContext * ctx , const char * field )
3777
+ {
3778
+ DataType type_out ;
3779
+ const JsonElement * os_rel = EvalContextVariableGetSpecial (
3780
+ ctx , SPECIAL_SCOPE_SYS , "os_release" , & type_out );
3781
+
3782
+ if (type_out != CF_DATA_TYPE_CONTAINER )
3783
+ {
3784
+ return NULL ;
3785
+ }
3786
+ const JsonElement * child = JsonObjectGet (os_rel , field );
3787
+ if (child == NULL )
3788
+ {
3789
+ return NULL ;
3790
+ }
3791
+ const char * result = JsonPrimitiveGetAsString (child );
3792
+ return result ;
3793
+ }
3794
+
3795
+ static void SysOSVersionMinor (EvalContext * ctx )
3796
+ {
3797
+ const char * version_id = OSReleaseGet (ctx , "VERSION_ID" );
3798
+
3799
+ char * minor ;
3800
+ if (version_id != NULL )
3801
+ {
3802
+ Item * version_tuple = SplitString (version_id , '.' );
3803
+
3804
+ if (version_tuple != NULL && version_tuple -> next != NULL )
3805
+ {
3806
+ minor = version_tuple -> next -> name ;
3807
+ }
3808
+ }
3809
+
3810
+ if (NULL_OR_EMPTY (minor ))
3811
+ {
3812
+ EvalContextVariablePutSpecial (ctx , SPECIAL_SCOPE_SYS ,
3813
+ "os_version_minor" , "Unknown" ,
3814
+ CF_DATA_TYPE_STRING , "source=agent" );
3815
+ }
3816
+ else
3817
+ {
3818
+ EvalContextVariablePutSpecial (ctx , SPECIAL_SCOPE_SYS ,
3819
+ "os_version_minor" , minor ,
3820
+ CF_DATA_TYPE_STRING ,
3821
+ "source=agent,derived-from=os_release" );
3822
+ }
3823
+ }
3824
+
3825
+
3774
3826
/*****************************************************************************/
3775
3827
3776
3828
void DetectEnvironment (EvalContext * ctx )
@@ -3785,4 +3837,5 @@ void DetectEnvironment(EvalContext *ctx)
3785
3837
GetDefVars (ctx );
3786
3838
SysOSNameHuman (ctx );
3787
3839
SysOsVersionMajor (ctx );
3840
+ SysOSVersionMinor (ctx );
3788
3841
}
0 commit comments