コード例 #1
0
        public void Delete(string id)
        {
            SegmentId segId = new SegmentId(id);

            Site site = segId.SiteId == null ? null : SiteHelper.GetSite(segId.SiteId.Value);

            if (segId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            HiddenSegment segment = HiddenSegmentsHelper.getSegments(site, segId.Path).Where(s => s.Segment.ToString().Equals(segId.Segment)).FirstOrDefault();

            if (segment != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, segId.Path, ManagementUnit.ResolveConfigScope());

                HiddenSegmentsHelper.DeleteSegment(segment, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
            return;
        }
コード例 #2
0
        public void Delete(string id)
        {
            UrlId urlId = new UrlId(id);

            Site site = urlId.SiteId == null ? null : SiteHelper.GetSite(urlId.SiteId.Value);

            if (urlId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            UrlRule url = UrlsHelper.GetUrls(site, urlId.Path).Where(u => u.Url.ToString().Equals(urlId.Url)).FirstOrDefault();

            if (url != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, urlId.Path, ManagementUnit.ResolveConfigScope());

                UrlsHelper.DeleteUrl(url, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
            return;
        }
コード例 #3
0
        private void ConfigureRequestFiltering()
        {
            // MVC routing
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "requestfiltering" });

            // Self
            Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", rf => new { href = RequestFilteringHelper.GetLocation(rf.id) });


            // Web Server
            Environment.Hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => {
                var id = GetRequestFilteringId(null, null);
                return(new { href = RequestFilteringHelper.GetLocation(id.Uuid) });
            });

            // Site
            Environment.Hal.ProvideLink(Sites.Defines.Resource.Guid, Defines.Resource.Name, site => {
                var siteId = new SiteId((string)site.id);
                Site s     = SiteHelper.GetSite(siteId.Id);
                var id     = GetRequestFilteringId(s, "/");
                return(new { href = RequestFilteringHelper.GetLocation(id.Uuid) });
            });

            // Application
            Environment.Hal.ProvideLink(Applications.Defines.Resource.Guid, Defines.Resource.Name, app => {
                var appId = new ApplicationId((string)app.id);
                Site s    = SiteHelper.GetSite(appId.SiteId);
                var id    = GetRequestFilteringId(s, appId.Path);
                return(new { href = RequestFilteringHelper.GetLocation(id.Uuid) });
            });
        }
コード例 #4
0
        public void Delete(string id)
        {
            QueryStringId queryStringId = new QueryStringId(id);

            Site site = queryStringId.SiteId == null ? null : SiteHelper.GetSite(queryStringId.SiteId.Value);

            if (queryStringId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            QueryStringRule queryString = QueryStringsHelper.GetQueryStrings(site, queryStringId.Path).FirstOrDefault(r => r.QueryString.ToString().Equals(queryStringId.QueryString));

            if (queryString != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, queryStringId.Path, ManagementUnit.ResolveConfigScope());

                QueryStringsHelper.DeleteQueryString(queryString, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
            return;
        }
コード例 #5
0
        public static List <UrlRule> GetUrls(Site site, string path)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path);


            // Consolidates the underlying allow query strings and deny query strings into a single collection
            List <UrlRule> urls = new List <UrlRule>();

            var allowedCollection = requestFilteringSection.AlwaysAllowedUrls;

            if (allowedCollection != null)
            {
                allowedCollection.ToList().ForEach(u => urls.Add(new UrlRule()
                {
                    Url   = u.Url.TrimStart(new char[] { '/' }),
                    Allow = true
                }));
            }

            var deniedCollection = requestFilteringSection.DenyUrlSequences;

            if (deniedCollection != null)
            {
                deniedCollection.ToList().ForEach(u => urls.Add(new UrlRule()
                {
                    Url   = u.Sequence,
                    Allow = false
                }));
            }

            return(urls);
        }
コード例 #6
0
        public static List <QueryStringRule> GetQueryStrings(Site site, string path)
        {
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path);

            // Consolidates the underlying allow query strings and deny query strings into a single collection
            List <QueryStringRule> queryStrings = new List <QueryStringRule>();

            var allowedCollection = requestFilteringSection.AlwaysAllowedQueryStrings;

            if (allowedCollection != null)
            {
                allowedCollection.ToList().ForEach(allowed => queryStrings.Add(new QueryStringRule()
                {
                    QueryString = allowed.QueryString,
                    Allow       = true
                }));
            }

            var deniedCollection = requestFilteringSection.DenyQueryStringSequences;

            if (deniedCollection != null)
            {
                deniedCollection.ToList().ForEach(allowed => queryStrings.Add(new QueryStringRule()
                {
                    QueryString = allowed.Sequence,
                    Allow       = false
                }));
            }

            return(queryStrings);
        }
コード例 #7
0
        public void Delete(string id)
        {
            RuleId ruleId = new RuleId(id);

            Site        site = ruleId.SiteId == null ? null : SiteHelper.GetSite(ruleId.SiteId.Value);
            Application app  = ApplicationHelper.GetApplication(ruleId.Path, site);

            if (ruleId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            Rule rule = RulesHelper.GetRules(site, ruleId.Path).Where(r => r.Name.ToString().Equals(ruleId.Name)).FirstOrDefault();

            if (rule != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, ruleId.Path, ManagementUnit.ResolveConfigScope());

                RulesHelper.DeleteRule(rule, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
        }
コード例 #8
0
        public static List <HiddenSegment> getSegments(Site site, string path)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path);

            var collection = requestFilteringSection.HiddenSegments;

            if (collection != null)
            {
                return(collection.ToList());
            }
            return(new List <HiddenSegment>());
        }
コード例 #9
0
        public async Task <object> Post()
        {
            if (RequestFilteringHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(RequestFilteringHelper.DISPLAY_NAME);
            }

            await RequestFilteringHelper.SetFeatureEnabled(true);

            dynamic settings = RequestFilteringHelper.ToJsonModel(null, null);

            return(Created(RequestFilteringHelper.GetLocation(settings.id), settings));
        }
コード例 #10
0
        public static List <VerbElement> GetVerbs(Site site, string path, string configPath = null)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path, configPath);

            var collection = requestFilteringSection.Verbs;

            if (collection != null)
            {
                return(collection.ToList());
            }
            return(new List <VerbElement>());
        }
コード例 #11
0
        public static List <HeaderLimit> GetHeaderLimits(Site site, string path, string configPath = null)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path, configPath);

            var collection = requestFilteringSection.RequestLimits.HeaderLimits;

            if (collection != null)
            {
                return(collection.ToList());
            }
            return(new List <HeaderLimit>());
        }
コード例 #12
0
        public static List <Extension> GetExtensions(Site site, string path, string configPath = null)
        {
            // Get request filtering section
            RequestFilteringSection requestFilteringSection = RequestFilteringHelper.GetRequestFilteringSection(site, path, configPath);

            var collection = requestFilteringSection.FileExtensions;

            if (collection != null)
            {
                return(collection.ToList());
            }
            return(new List <Extension>());
        }
コード例 #13
0
        public object Get(string id)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            if (reqId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            return(RequestFilteringHelper.ToJsonModel(site, reqId.Path));
        }
コード例 #14
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            if (path == null)
            {
                return(NotFound());
            }

            dynamic d = RequestFilteringHelper.ToJsonModel(site, path);

            return(LocationChanged(RequestFilteringHelper.GetLocation(d.id), d));
        }
コード例 #15
0
        public object Post([FromBody] dynamic model)
        {
            Rule rule = null;
            Site site = null;
            RequestFilteringId reqId = null;

            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            // Rule must be created for a specific request filtering section
            if (model.request_filtering == null)
            {
                throw new ApiArgumentException("request_filtering");
            }
            if (!(model.request_filtering is JObject))
            {
                throw new ApiArgumentException(String.Empty, "request_filtering");
            }
            string reqUuid = DynamicHelper.Value(model.request_filtering.id);

            if (reqUuid == null)
            {
                throw new ApiArgumentException("request_filtering.id");
            }

            // Get the feature id
            reqId = new RequestFilteringId(reqUuid);

            // Get site the rule is for if applicable
            site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            string configPath = ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            // Create filtering rule
            rule = RulesHelper.CreateRule(model, section);

            // Add it
            RulesHelper.AddRule(rule, section);

            // Save
            ManagementUnit.Current.Commit();

            //
            // Create response
            dynamic r = RulesHelper.ToJsonModel(rule, site, reqId.Path, null, true);

            return(Created(RulesHelper.GetLocation(r.id), r));
        }
コード例 #16
0
        public object Post([FromBody] dynamic model)
        {
            Extension extension = null;
            Site      site      = null;

            RequestFilteringId reqId = null;

            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            if (model.request_filtering == null)
            {
                throw new ApiArgumentException("request_filtering");
            }
            if (!(model.request_filtering is JObject))
            {
                throw new ApiArgumentException(String.Empty, "request_filtering");
            }
            string reqUuid = DynamicHelper.Value(model.request_filtering.id);

            if (reqUuid == null)
            {
                throw new ApiArgumentException("request_filtering.id");
            }

            // Get the feature id
            reqId = new RequestFilteringId(reqUuid);

            site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            string configPath = ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            extension = ExtensionsHelper.CreateExtension(model, section);

            ExtensionsHelper.AddExtension(extension, section);

            ManagementUnit.Current.Commit();

            //
            // Create response
            dynamic ext = ExtensionsHelper.ToJsonModel(extension, site, reqId.Path);

            return(Created(ExtensionsHelper.GetLocation(ext.id), ext));
        }
コード例 #17
0
        internal static object ToJsonModel(HiddenSegment segment, Site site, string path)
        {
            if (segment == null)
            {
                return(null);
            }

            SegmentId segmentId = new SegmentId(site?.Id, path, segment.Segment);

            var obj = new {
                segment           = segment.Segment,
                id                = segmentId.Uuid,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return(Core.Environment.Hal.Apply(Defines.HiddenSegmentsResource.Guid, obj));
        }
コード例 #18
0
        internal static object ToJsonModel(Extension extension, Site site, string path)
        {
            if (extension == null)
            {
                return(null);
            }
            ExtensionId extensionId = new ExtensionId(site?.Id, path, extension.FileExtension);

            var obj = new {
                extension         = extension.FileExtension.TrimStart(new char[] { '.' }),
                id                = extensionId.Uuid,
                allow             = extension.Allowed,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return(Core.Environment.Hal.Apply(Defines.FileExtensionsResource.Guid, obj));
        }
コード例 #19
0
        internal static object ToJsonModel(QueryStringRule queryString, Site site, string path)
        {
            if (queryString == null)
            {
                return(null);
            }

            QueryStringId id = new QueryStringId(site?.Id, path, queryString.QueryString);

            var obj = new {
                query_string      = queryString.QueryString,
                id                = id.Uuid,
                allow             = queryString.Allow,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return(Core.Environment.Hal.Apply(Defines.QueryStringResource.Guid, obj));
        }
コード例 #20
0
        internal static object ToJsonModel(HeaderLimit headerLimit, Site site, string path)
        {
            if (headerLimit == null)
            {
                return(null);
            }

            HeaderLimitId id = new HeaderLimitId(site?.Id, path, headerLimit.Header);

            var obj = new {
                header            = headerLimit.Header,
                id                = id.Uuid,
                size_limit        = headerLimit.SizeLimit,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return(Core.Environment.Hal.Apply(Defines.HeaderLimitsResource.Guid, obj));
        }
コード例 #21
0
        internal static object ToJsonModel(UrlRule url, Site site, string path)
        {
            if (url == null)
            {
                return(null);
            }

            UrlId urlId = new UrlId(site?.Id, path, url.Url);

            var obj = new {
                url               = url.Url,
                id                = urlId.Uuid,
                allow             = url.Allow,
                request_filtering = RequestFilteringHelper.ToJsonModelRef(site, path)
            };

            return(Core.Environment.Hal.Apply(Defines.UrlsResource.Guid, obj));
        }
コード例 #22
0
        public object Post([FromBody] dynamic model)
        {
            QueryStringRule    queryString = null;
            Site               site        = null;
            RequestFilteringId reqId       = null;

            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            if (model.request_filtering == null)
            {
                throw new ApiArgumentException("request_filtering");
            }
            if (!(model.request_filtering is JObject))
            {
                throw new ApiArgumentException("request_filtering");
            }
            string reqUuid = DynamicHelper.Value(model.request_filtering.id);

            if (reqUuid == null)
            {
                throw new ApiArgumentException("request_filtering.id");
            }

            reqId = new RequestFilteringId(reqUuid);

            site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            string configPath = ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            queryString = QueryStringsHelper.CreateQueryString(model);

            QueryStringsHelper.AddQueryString(queryString, section);

            ManagementUnit.Current.Commit();

            //
            // Create response
            dynamic qs = QueryStringsHelper.ToJsonModel(queryString, site, reqId.Path);

            return(Created(QueryStringsHelper.GetLocation(qs.id), qs));
        }
コード例 #23
0
        public void Delete(string id)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

            Site site = (reqId.SiteId != null) ? SiteHelper.GetSite(reqId.SiteId.Value) : null;

            if (site == null)
            {
                return;
            }

            var section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, ManagementUnit.ResolveConfigScope());

            section.RevertToParent();

            ManagementUnit.Current.Commit();
        }
コード例 #24
0
        public object Post([FromBody] dynamic model)
        {
            HiddenSegment      segment = null;
            Site               site    = null;
            RequestFilteringId reqId   = null;

            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            if (model.request_filtering == null)
            {
                throw new ApiArgumentException("request_filtering");
            }
            if (!(model.request_filtering is JObject))
            {
                throw new ApiArgumentException("request_filtering");
            }
            string reqUuid = DynamicHelper.Value(model.request_filtering.id);

            if (reqUuid == null)
            {
                throw new ApiArgumentException("request_filtering.id");
            }

            // Get the feature id
            reqId = new RequestFilteringId(reqUuid);

            site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            string configPath = ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            segment = HiddenSegmentsHelper.CreateSegment(model, section);

            HiddenSegmentsHelper.AddSegment(segment, section);

            ManagementUnit.Current.Commit();

            dynamic hidden_segment = HiddenSegmentsHelper.ToJsonModel(segment, site, reqId.Path);

            return(Created(HiddenSegmentsHelper.GetLocation(hidden_segment.id), hidden_segment));
        }
コード例 #25
0
        public object Post([FromBody] dynamic model)
        {
            HeaderLimit        headerLimit = null;
            Site               site        = null;
            RequestFilteringId reqId       = null;

            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            if (model.request_filtering == null)
            {
                throw new ApiArgumentException("request_filtering");
            }
            if (!(model.request_filtering is JObject))
            {
                throw new ApiArgumentException(String.Empty, "request_filtering");
            }
            string reqUuid = DynamicHelper.Value(model.request_filtering.id);

            if (reqUuid == null)
            {
                throw new ApiArgumentException("request_filtering.id");
            }

            reqId = new RequestFilteringId(reqUuid);

            site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            string configPath = ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            headerLimit = HeaderLimitsHelper.CreateHeaderLimit(model, section);

            HeaderLimitsHelper.AddHeaderLimit(headerLimit, section);

            ManagementUnit.Current.Commit();

            dynamic header_limit = HeaderLimitsHelper.ToJsonModel(headerLimit, site, reqId.Path);

            return(Created(HeaderLimitsHelper.GetLocation(header_limit.id), header_limit));
        }
コード例 #26
0
        public async Task Delete(string id)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

            Site site = (reqId.SiteId != null) ? SiteHelper.GetSite(reqId.SiteId.Value) : null;

            if (site != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, ManagementUnit.ResolveConfigScope());
                section.RevertToParent();
                ManagementUnit.Current.Commit();
            }

            if (reqId.SiteId == null && RequestFilteringHelper.IsFeatureEnabled())
            {
                await RequestFilteringHelper.SetFeatureEnabled(false);
            }
        }
コード例 #27
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            if (reqId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            // Check for config_scope
            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            RequestFilteringHelper.UpdateFeatureSettings(model, section);

            ManagementUnit.Current.Commit();

            return(RequestFilteringHelper.ToJsonModel(site, reqId.Path));
        }
コード例 #28
0
        public void Delete(string id)
        {
            ExtensionId extId = new ExtensionId(id);

            Site site = extId.SiteId == null ? null : SiteHelper.GetSite(extId.SiteId.Value);

            if (extId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            Extension extension = ExtensionsHelper.GetExtensions(site, extId.Path).Where(e => e.FileExtension.ToString().Equals(extId.FileExtension)).FirstOrDefault();

            if (extension != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, extId.Path, ManagementUnit.ResolveConfigScope());

                ExtensionsHelper.DeleteExtension(extension, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
        }
コード例 #29
0
        public void Delete(string id)
        {
            HeaderLimitId headerId = new HeaderLimitId(id);

            Site site = headerId.SiteId == null ? null : SiteHelper.GetSite(headerId.SiteId.Value);

            if (headerId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            HeaderLimit headerLimit = HeaderLimitsHelper.GetHeaderLimits(site, headerId.Path).Where(h => h.Header.ToString().Equals(headerId.Header)).FirstOrDefault();

            if (headerLimit != null)
            {
                var section = RequestFilteringHelper.GetRequestFilteringSection(site, headerId.Path, ManagementUnit.ResolveConfigScope());

                HeaderLimitsHelper.DeleteHeaderLimit(headerLimit, section);
                ManagementUnit.Current.Commit();
            }

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
        }
コード例 #30
0
        public static void UpdateQueryString(QueryStringRule queryString, dynamic model, Site site, string path, string configPath = null)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }
            if (queryString.QueryString == null)
            {
                throw new ArgumentNullException("queryString.QueryString");
            }
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            bool?  allow           = DynamicHelper.To <bool>(model.allow);
            string queryStringName = DynamicHelper.Value(model.query_string);

            // Empty change set
            if (string.IsNullOrEmpty(queryStringName) && allow == null)
            {
                return;
            }

            var section = RequestFilteringHelper.GetRequestFilteringSection(site, path, configPath);

            try {
                // Remove the old query string

                if (queryString.Allow)
                {
                    // We have to retrieve the configuration element from the allow collection
                    var allowCollection = section.AlwaysAllowedQueryStrings;
                    var allowElement    = allowCollection.First(s => s.QueryString.Equals(queryString.QueryString));

                    // Remove the query string from the allow collection
                    allowCollection.Remove(allowElement);
                }
                else
                {
                    var denyCollection = section.DenyQueryStringSequences;
                    var denyElement    = denyCollection.First(s => s.Sequence.Equals(queryString.QueryString));

                    denyCollection.Remove(denyElement);
                }
            }
            catch (FileLoadException e) {
                throw new LockedException(section.SectionPath, e);
            }
            catch (DirectoryNotFoundException e) {
                throw new ConfigScopeNotFoundException(e);
            }


            // Update the query string to its new state
            queryString.Allow       = allow == null ? queryString.Allow : allow.Value;
            queryString.QueryString = string.IsNullOrEmpty(queryStringName) ? queryString.QueryString : queryStringName;


            try {
                // Add the updated query string back into its respective collection

                if (queryString.Allow)
                {
                    // Insert the query string into the allow collection
                    section.AlwaysAllowedQueryStrings.Add(queryString.QueryString);
                }
                else
                {
                    // Insert the query string into the deny collection
                    section.DenyQueryStringSequences.Add(queryString.QueryString);
                }
            }
            catch (FileLoadException e) {
                throw new LockedException(section.SectionPath, e);
            }
            catch (DirectoryNotFoundException e) {
                throw new ConfigScopeNotFoundException(e);
            }
        }