public void VerifyDataTypeFileStreamInformation( FileStreamInformation fileStreamInformation, bool isMultipleEntriesPresent, bool isNoOtherEntriesFollow) { Site.DefaultProtocolDocShortName = "MS-FSCC"; // if multiple entries are present if (isMultipleEntriesPresent) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1659 ,the NextEntryOffset is : {0}.", fileStreamInformation.NextEntryOffset); // // Verify requirement 1659 // // Verify the type and the value of the NextEntryOffset // As it's unable for us to verify the NextEntryOffset, we only check if the value is in the valid range. bool isVerifyR1659 = ( fileStreamInformation.NextEntryOffset.GetType() == typeof(UInt32) && fileStreamInformation.NextEntryOffset <= fileStreamInformation.StreamAllocationSize); Site.CaptureRequirementIfIsTrue( isVerifyR1659, 1659, @"[In FILE_STREAM_INFORMATION]NextEntryOffset (4 bytes): A 32-bit unsigned integer that contains the byte offset from the beginning of this entry, at which the next FILE_ STREAM _INFORMATION entry is located, if multiple entries are present in a buffer."); } //if no other entries follow this one[FILE_ STREAM _INFORMATION entry]. if (isNoOtherEntriesFollow) { // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1660"); // // Verify requirement 1660 // // Verify the value of NextEntryOffset Site.CaptureRequirementIfAreEqual<uint>( 0, fileStreamInformation.NextEntryOffset, 1660, @"[In FILE_STREAM_INFORMATION]NextEntryOffset (4 bytes): This member is zero if no other entries follow this one[FILE_ STREAM _INFORMATION entry]."); } // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1663 Actual StreamNameLength: {0}, Expected StreamNameLength: {1}.", fileStreamInformation.StreamNameLength, fileStreamInformation.StreamName.Length); // // Verify requirement 1663 // // Verify the type and the value of the StreamNameLength bool isVerified_r1663 = ( fileStreamInformation.StreamNameLength.GetType() == typeof(UInt32) && fileStreamInformation.StreamNameLength == fileStreamInformation.StreamName.Length); Site.CaptureRequirementIfIsTrue( isVerified_r1663, 1663, @"[In FILE_STREAM_INFORMATION]StreamNameLength (4 bytes): A 32-bit unsigned integer that contains the length, in bytes, of the stream name string."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1664 "); // // Verify requirement 1664 // // Verify the type and the value of the StreamSize // As it's unable for us to verify the StreamSize, we didn't verify here. Site.CaptureRequirementIfAreEqual<Type>( typeof(UInt64), fileStreamInformation.StreamSize.GetType(), 1664, @"[In FILE_STREAM_INFORMATION]StreamSize (8 bytes): A 64-bit signed integer that contains the size, in bytes, of the stream."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1665 StreamSize is : {0}", fileStreamInformation.StreamSize); // // Verify requirement 1665 // // As the type is verified above, we didn't verify here again Site.CaptureRequirementIfIsTrue( fileStreamInformation.StreamSize >= 0, 1665, @"[In FILE_STREAM_INFORMATION]StreamSize (8 bytes): The value of this field MUST be greater than or equal to 0."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1666"); // // Verify requirement 1666 // // Verify the type and the value of the StreamAllocationSize // As it's unable for us to verify if the StreamAllocationSize is valid, we only verify the type here Site.CaptureRequirementIfAreEqual<Type>( typeof(Int64), fileStreamInformation.StreamAllocationSize.GetType(), 1666, @"[In FILE_STREAM_INFORMATION]StreamAllocationSize (8 bytes): A 64-bit signed integer that contains the file stream allocation size in bytes."); // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1668 Actual StreamAllocationSize: {0}", fileStreamInformation.StreamAllocationSize); // // Verify requirement 1668 // // Verify the value of the StreamAllocationSize Site.CaptureRequirementIfIsTrue( (fileStreamInformation.StreamAllocationSize >= 0), 1668, @"[In FILE_STREAM_INFORMATION]StreamAllocationSize (8 bytes): The value of this field MUST be greater than or equal to 0."); // Since this rs is informative, we capture it directly Site.CaptureRequirement( 1670, @"[In FILE_STREAM_INFORMATION]StreamName (variable): The :$DATA string that follows streamname is an internal data type tag that is unintentionally exposed via this info class."); // Since the structure of the StreamName is verified when capturing the 1671 // We capture this ts directly Site.CaptureRequirement( 1672, @"[In FILE_STREAM_INFORMATION]StreamName (variable): The leading ¡®:¡¯ and trailing ¡®:$DATA¡¯ characters MUST be stripped from this field to derive the actual stream name."); string defaultStream = BytesToString(fileStreamInformation.StreamName); // if the stream name is empty if (defaultStream == String.Empty) { // Since the default StreamName is defined by system // We capture this ts directly if the streamname is empty. Site.CaptureRequirement( 1673, @"[In FILE_STREAM_INFORMATION]StreamName (variable): A resulting empty string for the stream name denotes the default stream."); } // // Add the debug information // Site.Log.Add(LogEntryKind.Debug, "Verify MS-FSCC_R1714"); // // Verify requirement 1714 // // According to the rs, this field MUST be handled as a sequence of StreamNameLength bytes. // We verify the length of the StreamName Site.CaptureRequirementIfAreEqual<int>( fileStreamInformation.StreamName.Length , (int)fileStreamInformation.StreamNameLength, 1714, @"[In FILE_STREAM_INFORMATION]StreamName (variable): This field MUST be handled as a sequence of StreamNameLength bytes."); // As the portions of a buffer that are within a FILE_STREAM_INFORMATION is verified above // We capture this rs directly as the data element not in a FILE_STREAM_INFORMATION can be set to any value Site.CaptureRequirement( 1656, @"[In FileStreamInformation]Any portions of a buffer that are not within a FILE_STREAM_INFORMATION data element can contain any value."); // As all the elements in the FILE_STREAM_INFORMATION have been verified above // This rs will be captured directly Site.CaptureRequirement( 1658, @"[In FileStreamInformation] The FILE_STREAM_INFORMATION data element is as follows:[NextEntryOffset, StreamNameLength, StreamSize, ..., StreamAllocationSize, ..., StreamName (variable)]."); Site.DefaultProtocolDocShortName = Site.Properties["ProtocolShortName"]; }
/// <summary> /// Parse the outputBuffer to a list of FileStreamInformation structures /// </summary> /// <param name="outputBuffer">The outputBuffer returned from server</param> /// <returns>A list of FileStreamInformation structures</returns> private List<FileStreamInformation> ParseFileStreamInformations(byte[] outputBuffer) { List<FileStreamInformation> fileStreamInformations = new List<FileStreamInformation>(); FileStreamInformation fileStreamInformation = new FileStreamInformation(); int offset = 0; fileStreamInformation = TypeMarshal.ToStruct<FileStreamInformation>(outputBuffer); fileStreamInformations.Add(fileStreamInformation); while (fileStreamInformation.NextEntryOffset != 0) { offset += (int)(fileStreamInformation.NextEntryOffset); int temp = offset; fileStreamInformation = TypeMarshal.ToStruct<FileStreamInformation>(outputBuffer, ref temp); fileStreamInformations.Add(fileStreamInformation); } return fileStreamInformations; }