private FileDataVersionOne CreateFileDataVersionOne(Artifact v2FileData)
        {
            FileDataVersionOne fileData = null;

            if (v2FileData != null)
            {
                int    parentIndex = v2FileData.ParentIndex;
                string parentKey   = parentIndex == -1
                    ? null
                    : _v2FileIndexToV1KeyMap?[parentIndex];

                fileData = new FileDataVersionOne
                {
                    Hashes     = CreateHashVersionOneListFromV2Hashes(v2FileData.Hashes),
                    Length     = v2FileData.Length,
                    MimeType   = v2FileData.MimeType,
                    Offset     = v2FileData.Offset,
                    ParentKey  = parentKey,
                    Properties = v2FileData.Properties,
                    Uri        = v2FileData.Location?.Uri,
                    UriBaseId  = v2FileData.Location?.UriBaseId
                };

                if (v2FileData.Contents != null)
                {
                    fileData.Contents = MimeType.IsTextualMimeType(v2FileData.MimeType) ?
                                        SarifUtilities.GetUtf8Base64String(v2FileData.Contents.Text) :
                                        v2FileData.Contents.Binary;
                }
            }

            return(fileData);
        }
Esempio n. 2
0
        internal FileDataVersionOne CreateFileData(FileData v2FileData)
        {
            FileDataVersionOne fileData = null;

            if (v2FileData != null)
            {
                fileData = new FileDataVersionOne
                {
                    Hashes     = v2FileData.Hashes?.Select(CreateHash).ToList(),
                    Length     = v2FileData.Length,
                    MimeType   = v2FileData.MimeType,
                    Offset     = v2FileData.Offset,
                    ParentKey  = v2FileData.ParentKey,
                    Properties = v2FileData.Properties,
                    Uri        = v2FileData.FileLocation?.Uri,
                    UriBaseId  = v2FileData.FileLocation?.UriBaseId
                };

                if (v2FileData.Contents != null)
                {
                    fileData.Contents = MimeType.IsTextualMimeType(v2FileData.MimeType) ?
                                        SarifUtilities.GetUtf8Base64String(v2FileData.Contents.Text) :
                                        v2FileData.Contents.Binary;
                }
            }

            return(fileData);
        }