Beispiel #1
0
        public void PublishFrames(string fileName)
        {
            using (Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                try
                {
                    var        tagModel   = TagManager.Deserialize(stream);
                    SourceFile sourceFile = new SourceFile()
                    {
                        FileName = Path.GetFileName(fileName),
                        FilePath = Path.GetDirectoryName(fileName)
                    };

                    foreach (var frame in tagModel)
                    {
                        SourceFileTag fileTag = new SourceFileTag()
                        {
                            Tag = frame.FrameId
                        };
                        sourceFile.SourceFileTag.Add(fileTag);

                        if (frame is FrameText)
                        {
                            FrameText frameType = (FrameText)frame;
                            fileTag.TagText = new TagText()
                            {
                                Text           = frameType.Text,
                                TextEncodingId = (byte)frameType.TextCode
                            };
                            continue;
                        }

                        if (frame is FrameTextUserDef)
                        {
                            FrameTextUserDef frameType = (FrameTextUserDef)frame;
                            fileTag.TagText = new TagText()
                            {
                                Text           = frameType.Text,
                                Description    = frameType.Description,
                                TextEncodingId = (byte)frameType.TextCode
                            };
                            continue;
                        }

                        if (frame is FrameUrl)
                        {
                            FrameUrl frameType = (FrameUrl)frame;
                            fileTag.TagText = new TagText()
                            {
                                Text = frameType.Url
                            };
                            continue;
                        }

                        if (frame is FrameUrlUserDef)
                        {
                            FrameUrlUserDef frameType = (FrameUrlUserDef)frame;
                            fileTag.TagText = new TagText()
                            {
                                Text           = frameType.URL,
                                Description    = frameType.Description,
                                TextEncodingId = (byte)frameType.TextCode
                            };
                            continue;
                        }

                        if (frame is FrameFullText)
                        {
                            FrameFullText frameType = (FrameFullText)frame;
                            fileTag.TagFullText = new TagFullText()
                            {
                                TextEncodingId = (byte)frameType.TextCode,
                                Description    = frameType.Description,
                                TextLanguage   = frameType.Language,
                                Comment        = frameType.Text
                            };
                            continue;
                        }

                        if (frame is FramePicture)
                        {
                            FramePicture frameType = (FramePicture)frame;
                            fileTag.TagPicture = new TagPicture()
                            {
                                PictureTypeId = (byte)frameType.PictureType,
                                MimeType      = frameType.Mime,
                                Description   = frameType.Description,
                                BinaryImage   = frameType.PictureData
                            };
                            continue;
                        }

                        if (frame is FrameBinary)
                        {
                            FrameBinary frameType = (FrameBinary)frame;
                            fileTag.TagBinary = new TagBinary()
                            {
                                TextEncodingId = (byte)frameType.TextEncoding,
                                MimeType       = frameType.Mime,
                                Description    = frameType.Description,
                                BinaryObject   = frameType.ObjectData
                            };
                            continue;
                        }
                    }
                    _dataContext.SourceFile.InsertOnSubmit(sourceFile);
                    _dataContext.SubmitChanges();
                }
                catch (NotImplementedException e)
                {
                    Console.WriteLine("{0}:{1}", fileName, e.Message);
                }
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (FindingType.Length != 0)
            {
                hash ^= FindingType.GetHashCode();
            }
            if (Severity != global::Google.Cloud.WebSecurityScanner.V1.Finding.Types.Severity.Unspecified)
            {
                hash ^= Severity.GetHashCode();
            }
            if (HttpMethod.Length != 0)
            {
                hash ^= HttpMethod.GetHashCode();
            }
            if (FuzzedUrl.Length != 0)
            {
                hash ^= FuzzedUrl.GetHashCode();
            }
            if (Body.Length != 0)
            {
                hash ^= Body.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (ReproductionUrl.Length != 0)
            {
                hash ^= ReproductionUrl.GetHashCode();
            }
            if (FrameUrl.Length != 0)
            {
                hash ^= FrameUrl.GetHashCode();
            }
            if (FinalUrl.Length != 0)
            {
                hash ^= FinalUrl.GetHashCode();
            }
            if (TrackingId.Length != 0)
            {
                hash ^= TrackingId.GetHashCode();
            }
            if (form_ != null)
            {
                hash ^= Form.GetHashCode();
            }
            if (outdatedLibrary_ != null)
            {
                hash ^= OutdatedLibrary.GetHashCode();
            }
            if (violatingResource_ != null)
            {
                hash ^= ViolatingResource.GetHashCode();
            }
            if (vulnerableHeaders_ != null)
            {
                hash ^= VulnerableHeaders.GetHashCode();
            }
            if (vulnerableParameters_ != null)
            {
                hash ^= VulnerableParameters.GetHashCode();
            }
            if (xss_ != null)
            {
                hash ^= Xss.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }