示例#1
0
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var fieldValue = GetFieldValue(field.Name, renderingElement, renderingItem);
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                if (IsSentenceStyle(fieldValue))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "Button texts should be written in sentence style", string.Format("The button text \"{0}\" is not written in the correct style [{1}, {2}].", fieldValue, GetFieldValue("Id", renderingElement, renderingItem), field.Name), "Write all button text in sentence style. This means that only the first letter of the first word is capitalized.", item);
            }
        }
示例#2
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            if (item.TemplateID != TemplateIDs.Template)
            {
                return;
            }

            var layoutField = item.Fields[FieldIDs.LayoutField];

            if (layoutField.ContainsStandardValue)
            {
                return;
            }

            var value = GetFieldValuePipeline.Run().WithParameters(layoutField).Value;

            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Layout on template", "Assigning layouts on templates are no longer recommended.", "Assign the layout on the standard values item.", item);
        }
示例#3
0
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var fieldValue = GetFieldValue(field.Name, renderingElement, renderingItem);
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                if (fieldValue.IndexOf("<", StringComparison.InvariantCultureIgnoreCase) < 0)
                {
                    continue;
                }

                if (fieldValue.IndexOf(">", StringComparison.InvariantCultureIgnoreCase) < 0)
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "HTML code should not be embedded in the UI text labels.", string.Format("The label text \"{0}\" has Html code embedded [{1}, {2}].", fieldValue, GetFieldValue("Id", renderingElement, renderingItem), field.Name), "Remove HTML code from labels and only use the SPEAK style sheet for UI labels.", item);
            }
        }
示例#4
0
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var fieldValue = GetFieldValue(field.Name, renderingElement, renderingItem);
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                if (fieldValue.EndsWith(":") && !fieldValue.EndsWith(" :"))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "Label texts should end with a colon", string.Format("The label text \"{0}\" should end with a colon [{1}, {2}].", fieldValue, GetFieldValue("Id", renderingElement, renderingItem), field.Name), "Add a colon to the label, without a space between the label and the colon.", item);
            }
        }
示例#5
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            var rules = item.Security.GetAccessRules();

            foreach (var rule in rules)
            {
                if (rule.Account.AccountType != AccountType.User)
                {
                    continue;
                }

                if (rule.Account.Name == "sitecore\\Anonymous")
                {
                    continue;
                }

                if (rule.Account.Name == "$currentuser")
                {
                    continue;
                }

                output.Write(SeverityLevel.Suggestion, "Security assigned to user", string.Format("\"{0}\" is assigned to the user \"{1}\". It is recommended to assign security to roles only.", rule.AccessRight.Title, rule.Account.DisplayName), "Assign security to a role.", item);
                break;
            }
        }
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            bool isValid;

            try
            {
                try
                {
                    isValid = AuthenticationManager.Login("sitecore\\admin", "b", false);
                }
                catch (NullReferenceException ex)
                {
                    if (!ex.StackTrace.Contains("FormsAuthentication.SetAuthCookie"))
                    {
                        throw;
                    }

                    isValid = true;
                }
            }
            catch (Exception ex)
            {
                output.Write(SeverityLevel.Hint, "Administrator password changed", "An exception occured while checking the administrator password. The password may or may not have been changed: " + ex.Message, "The administrator password must be changed. To change it, open the User Manager in the Sitecore web client and change the password for \"sitecore\\admin\".");
                return;
            }

            if (isValid)
            {
                return;
            }

            output.Write(SeverityLevel.Error, "Administrator password changed", "The administrator password has not been changed.", "The administrator password must be changed. To change it, open the User Manager in the Sitecore web client and change the password for \"sitecore\\admin\".");
        }
        private void CheckWriteableFolder([NotNull] ValidationWriter output, [NotNull] string folder)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(folder, nameof(folder));

            if (!Directory.Exists(folder))
            {
                return;
            }

            var fileName = Path.Combine(folder, "file.tmp");
            var n        = 0;

            while (File.Exists(fileName))
            {
                fileName = Path.Combine(folder, string.Format("file{0}.tmp", n));
                n++;
            }

            try
            {
                FileUtil.WriteToFile(fileName, "write test");
                FileUtil.Delete(fileName);
            }
            catch (Exception ex)
            {
                output.Write(SeverityLevel.Error, "Folder without required write permission", string.Format("The folder \"{0}\" is not writable by the ASP.NET user: {1}", FileUtil.UnmapPath(folder, false), ex.Message), string.Format("Ensure that the ASP.NET user has write permission to the folder: {0}", FileUtil.UnmapPath(folder, false)));
            }
        }
示例#8
0
        private void LoadConfigFiles([NotNull] ValidationWriter output, [NotNull] string folder)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(folder, nameof(folder));

            foreach (var fileName in Directory.GetFiles(folder, "*.config"))
            {
                if ((File.GetAttributes(fileName) & FileAttributes.Hidden) != 0)
                {
                    continue;
                }

                try
                {
                    XDocument.Load(fileName);
                }
                catch (Exception ex)
                {
                    output.Write(SeverityLevel.Error, "Wellformed include config files", string.Format("The include config file \"{0}\" is not wellformed: {1}", FileUtil.UnmapPath(fileName, false), ex.Message), "Correct the error or delete the file.");
                }
            }

            foreach (var subfolder in Directory.GetDirectories(folder))
            {
                LoadConfigFiles(output, subfolder);
            }
        }
示例#9
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            var children = item.Children;

            for (var i0 = 0; i0 < children.Count; i0++)
            {
                var item0 = children[i0];
                if (string.IsNullOrEmpty(item0.DisplayName))
                {
                    return;
                }

                for (var i1 = i0 + 1; i1 < children.Count; i1++)
                {
                    var item1 = children[i1];

                    if (string.Compare(item0.DisplayName, item1.DisplayName, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        output.Write(SeverityLevel.Suggestion, "Items with same display name on same level", string.Format("Two or more items have the same display name \"{0}\" on the same level.", item0.DisplayName), "Change the display name of one or more of the items.", item0);
                    }
                }
            }
        }
示例#10
0
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            var license = License.VerifiedLicense();

            if (license == null)
            {
                return;
            }

            foreach (var module in GetModules(license))
            {
                var node = license.SelectSingleNode("/verifiedlicense/module[name='" + module + "']");

                var expiration = XmlUtil.GetChildValue("expiration", node);
                if (expiration.Length >= 0)
                {
                    continue;
                }

                var expires = DateUtil.IsoDateToDateTime(expiration);
                if (expires <= DateTime.UtcNow + new TimeSpan(14, 0, 0, 0))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "License about to expire", string.Format("The license \"{0}\" expires in {1} days.", module, (expires - DateTime.UtcNow).Days), "The web site may stop working when the license expires. Contact your Sitecore partner to obtain a new license.");
            }
        }
示例#11
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            if (StandardValuesManager.IsStandardValuesHolder(item))
            {
                return;
            }

            var layoutField = item.Fields[FieldIDs.LayoutField];

            if (layoutField == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(layoutField.Value))
            {
                return;
            }

            if (layoutField.ContainsStandardValue)
            {
                return;
            }

            if (layoutField.Value != layoutField.GetStandardValue())
            {
                output.Write(SeverityLevel.Suggestion, "Layout on item overrides layout on standard values item", "The layout on the item overrides the layout on the standard values item. Changing the layout on the standard values item will not change the layout on this item.", "Change the layout so it accommodates both layouts and store that layout on the standard values item.", item);
            }
        }
        protected override void WriteError(ValidationWriter output, Item item)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(item, nameof(item));

            output.Write(SeverityLevel.Suggestion, "Valid From/Valid To dates", "The Valid From date is after the Valid To date.", "Change either the Valid From date or the Valid To date.", item);
        }
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            var parameters = new UrlString(renderingElement.GetAttributeValue("par"));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var result = HttpUtility.UrlDecode(parameters[field.Name]);
                if (string.IsNullOrEmpty(result))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "Versionable parameters should be specified in the configuration items.", string.Format("The field \"{0}\" is versionable and is specified in the layout [{1}].", field.Name, GetFieldValue("Id", renderingElement, renderingItem)), "Enter all UI text in the standard item fields of configuration items.", item);
            }
        }
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            if (item.TemplateID != TemplateIDs.TemplateField)
            {
                return;
            }

            var source = item[FieldIDs.Source];

            if (string.IsNullOrEmpty(source))
            {
                return;
            }

            if (!source.StartsWith("/sitecore"))
            {
                return;
            }

            var sourceItem = item.Database.GetItem(source);

            if (sourceItem == null)
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Use IDs instead of paths in template fields", string.Format("The template field Source field contains the path \"{0}\". It is recommended to use IDs instead.", source), string.Format("Replace the path with the ID \"{0}\".", sourceItem.ID.ToString()), item);
        }
示例#15
0
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var fieldValue = GetFieldValue(field.Name, renderingElement, renderingItem);
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                if (IsHeadingStyle(fieldValue))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "Heading text should be written in heading style", string.Format("The heading text \"{0}\"is not written in heading style [{1}, {2}].", fieldValue, GetFieldValue("Id", renderingElement, renderingItem), field.Name), "Write all headings in heading style using heading capitalization. This means that the first letter of all nouns, verbs, and adverbs (but not articles, conjunctions, or prepositions) are capitalized. For example, The Quick Brown Fox Jumps over the Lazy Dog.", item);
            }
        }
示例#16
0
        public override void Check(ValidationWriter output, Item item, XElement renderingElement, Item renderingItem)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));
            Assert.ArgumentNotNull(renderingElement, nameof(renderingElement));
            Assert.ArgumentNotNull(renderingItem, nameof(renderingItem));

            foreach (var field in GetParametersTemplateFields(renderingItem))
            {
                if (!FieldContainsText(field, renderingElement, renderingItem))
                {
                    continue;
                }

                var fieldValue = GetFieldValue(field.Name, renderingElement, renderingItem);
                if (string.IsNullOrEmpty(fieldValue))
                {
                    continue;
                }

                if (IsSentenceStyle(fieldValue))
                {
                    continue;
                }

                output.Write(SeverityLevel.Warning, "General text should be written in sentence style", string.Format("The general text \"{0}\" is not written in sentence style [{1}, {2}].", fieldValue, GetFieldValue("Id", renderingElement, renderingItem), field.Name), "If the text is not being used as a heading, it must be written in sentence style. This means that only the first letter of the first word of each sentence is capitalized. For example, The quick brown fox jumps over the lazy dog.", item);
            }
        }
示例#17
0
        public override void Check(ValidationWriter output, Item item)
        {
            var parametersTemplateId = item[ParametersTemplateFieldId];

            if (string.IsNullOrEmpty(parametersTemplateId))
            {
                return;
            }

            var parameterTemplateItem = item.Database.GetItem(parametersTemplateId);

            if (parameterTemplateItem == null)
            {
                return;
            }

            var template = new TemplateItem(parameterTemplateItem);

            foreach (var templateFieldItem in template.Fields)
            {
                var templateItem = new TemplateItem(templateFieldItem.InnerItem.Parent.Parent);
                if (!templateItem.BaseTemplates.Any())
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(templateFieldItem.ToolTip) && !templateFieldItem.ToolTip.EndsWith("."))
                {
                    output.Write(SeverityLevel.Suggestion, "Parameter help text must end with a dot", string.Format("The help text for the '{0}' parameter in the control '{1}' must be a complete sentence and end with a dot.", templateFieldItem.Name, item.Name), "Add a dot to the help text.", templateFieldItem.InnerItem);
                }
            }
        }
示例#18
0
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            foreach (var siteName in Factory.GetSiteNames())
            {
                switch (siteName.ToLowerInvariant())
                {
                case "shell":
                case "login":
                case "admin":
                case "service":
                case "modules_shell":
                case "modules_website":
                case "scheduler":
                case "system":
                case "testing":
                case "publisher":
                    continue;
                }

                var site = Factory.GetSite(siteName);
                if (site == null)
                {
                    continue;
                }

                if (!site.CacheHtml)
                {
                    output.Write(SeverityLevel.Suggestion, "Enable Html caching", string.Format("Html caching is disabled for the site \"{0}\". Performance may suffer.", siteName), string.Format("Set the \"cacheHtml\" setting to \"true\" for the site \"{0}\" in the web.config.", siteName));
                }
            }
        }
示例#19
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            var parametersTemplateId = item[ParametersTemplateFieldId];

            if (string.IsNullOrEmpty(parametersTemplateId))
            {
                return;
            }

            var parameterTemplateItem = item.Database.GetItem(parametersTemplateId);

            if (parameterTemplateItem == null)
            {
                return;
            }

            var template = new TemplateItem(parameterTemplateItem);

            foreach (var templateFieldItem in template.Fields)
            {
                var templateItem = new TemplateItem(templateFieldItem.InnerItem.Parent.Parent);
                if (!templateItem.BaseTemplates.Any())
                {
                    continue;
                }

                if (string.IsNullOrEmpty(templateFieldItem.ToolTip))
                {
                    output.Write(SeverityLevel.Suggestion, "Parameter must have help text", string.Format("The parameter '{0}' in the '{1}' control does not have a short help text. The short help text is part of documentation and is displayed in the Documentation web site", templateFieldItem.Name, item.Name), "Write a help text.", templateFieldItem.InnerItem);
                }
            }
        }
示例#20
0
        private void CheckWritableWebFolder([NotNull] ValidationWriter output, [NotNull] string folder)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(folder, nameof(folder));

            folder = FileUtil.MapPath(folder);

            CheckWriteableFolder(output, folder);
        }
示例#21
0
        private void CheckWritableDataFolder([NotNull] ValidationWriter output, [NotNull] string folder)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(folder, nameof(folder));

            folder = Path.Combine(FileUtil.MapPath(Settings.DataFolder), folder);

            CheckWriteableFolder(output, folder);
        }
示例#22
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            var validatorCollection = ValidatorManager.BuildValidators(ValidatorsMode.ValidateButton, item);

            ValidatorManager.Validate(validatorCollection, options);

            foreach (BaseValidator validator in validatorCollection)
            {
                if (validator.Result == ValidatorResult.Valid || validator.Result == ValidatorResult.Unknown)
                {
                    continue;
                }

                var severity = SeverityLevel.None;

                switch (validator.Result)
                {
                case ValidatorResult.Unknown:
                case ValidatorResult.Valid:
                    severity = SeverityLevel.None;
                    break;

                case ValidatorResult.Suggestion:
                    severity = SeverityLevel.Suggestion;
                    break;

                case ValidatorResult.Warning:
                    severity = SeverityLevel.Warning;
                    break;

                case ValidatorResult.Error:
                case ValidatorResult.CriticalError:
                case ValidatorResult.FatalError:
                    severity = SeverityLevel.Error;
                    break;
                }

                if (severity == SeverityLevel.None)
                {
                    continue;
                }

                var category      = "Item Validation";
                var validatorItem = item.Database.GetItem(validator.ValidatorID);
                if (validatorItem != null)
                {
                    category = "Validation: " + validatorItem.Parent.Name;
                }

                output.Write(severity, category + " - " + validator.Name, validator.Text, string.Empty, item);
            }
        }
示例#23
0
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            if (Settings.Caching.Enabled)
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Enable caching", "Caching is disabled.", "Set the setting \"Caching.Enabled\" to true in the web.config.");
        }
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            if (!string.IsNullOrEmpty(Settings.MailServer))
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Configure mail server in web.config", "The mail server settings in web.config are missing.", "It is recommended to set the \"MailServer\", \"MailServerPort\", \"MailServerUserName\" and \"MailServerPassword\" settings in web.config.");
        }
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            if (!FileUtil.MapPath(Settings.DataFolder).StartsWith(FileUtil.MapPath("/"), StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            output.Write(SeverityLevel.Warning, "Data folder location", string.Format("The Data folder is located inside the web site root in \"{0}\". This is a potential security risk.", Settings.DataFolder), "Move the Data folder outside the web site root and change the \"DataFolder\" setting in the web.config to point to the new location.");
        }
        public override void Check(ValidationWriter output, Item item)
        {
            var fileName = "/sitecore/shell/client/Sitecore/Content/Speak/Documentation/Examples/" + item.Name + ".cshtml";

            if (FileUtil.FileExists(fileName))
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Control does not have an Example file", string.Format("The control '{0}' does not have an example file in the Documentation web site. All controls must have an example.", item.Name), "Create an Example file in this location: " + fileName, item);
        }
示例#27
0
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            if (!Settings.Profiling.SheerUI)
            {
                return;
            }

            output.Write(SeverityLevel.Suggestion, "Sheer UI profiling", "Sheer UI profiling is enabled.", "It is recommended that Sheer UI Profiling is disabled. To disable Sheer UI Profiling, open the web.config and set the setting \"Profiling.SheerUI\" to \"false\".");
        }
示例#28
0
        public override void Check(ValidationWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            if (Settings.Indexing.UpdateInterval != TimeSpan.Zero)
            {
                return;
            }

            output.Write(SeverityLevel.Warning, "Enable indexing", "Indexing should be enabled to increase performance.", "To enable indexing, set the setting \"Indexing.UpdateInterval\" to a value other than \"00:00:00\" in the web.config.");
        }
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            if (item.Publishing.NeverPublish)
            {
                return;
            }

            base.Check(output, item);
        }
示例#30
0
        public override void Check(ValidationWriter output, Item item)
        {
            if (!string.IsNullOrEmpty(item.Help.ToolTip) && !item.Help.ToolTip.EndsWith("."))
            {
                output.Write(SeverityLevel.Suggestion, "Control short help text must end with a dot", string.Format("The short help text for the control '{0}' must be a complete sentence and end with a dot.", item.Name), "Add a dot to the short help text.", item);
            }

            if (!string.IsNullOrEmpty(item.Help.Text) && !item.Help.Text.EndsWith("."))
            {
                output.Write(SeverityLevel.Suggestion, "Control long help text must end with a dot", string.Format("The long help text for the control '{0}' must be a complete sentence and end with a dot.", item.Name), "Add a dot to the long help text.", item);
            }
        }