Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

PSSA v1.18 is giving errors with subclasses #317

Closed
ykuijs opened this issue Mar 25, 2019 · 2 comments
Closed

PSSA v1.18 is giving errors with subclasses #317

ykuijs opened this issue Mar 25, 2019 · 2 comments
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.

Comments

@ykuijs
Copy link
Contributor

ykuijs commented Mar 25, 2019

Details of the problem, bug, or enhancement

With the release of PSScriptAnalyzer v1.18, several resources in SharePointDsc are giving false positives:
The following PSScriptAnalyzer rule 'PSDSCUseIdenticalMandatoryParametersForDSC' errors need to be fixed:
MSFT_SPSearchContentSource.psm1 (Line 1): The 'Required' parameter 'ScheduleType' is not present in 'Get-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 219): The 'Required' parameter 'ScheduleType' is not present in 'Set-TargetResource' DSC resource function(s).
MSFT_SPSearchContentSource.psm1 (Line 683): The 'Required' parameter 'ScheduleType' is not present in 'Test-TargetResource' DSC resource function(s).

The specified parameter however are parameters in subclasses, which should not be present in the *-TargetResource methods.

The specified parameter 'ScheduleType' exists in the class MSFT_SPSearchCrawlSchedule, not in MSFT_SPSearchContentSource which is implemented in the psm1 files:

[ClassVersion("1.0.0")]
Class MSFT_SPSearchCrawlSchedule
{
    [Required, Description("How frequently should this crawl be run"), ValueMap{"None","Daily","Weekly","Monthly"}, Values{"None","Daily","Weekly","Monthly"}] String ScheduleType;
    [Write, Description("Monthly crawls only: Which day of the month should the crawl run on")] Uint32 CrawlScheduleDaysOfMonth;
    [Write, Description("Weekly crawls only: What days should the crawl be run on"), ValueMap{"Everyday", "Weekdays", "Weekends", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}, Values{"Everyday", "Weekdays", "Weekends", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}] String CrawlScheduleDaysOfWeek[];
    [Write, Description("Monthly crawls only: Which months should this crawl be run during"), ValueMap{"AllMonths", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, Values{"AllMonths", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}] String CrawlScheduleMonthsOfYear[];
    [Write, Description("The hour of the day that the schedule should begin")] Uint32 StartHour;
    [Write, Description("The minute of the specified hour that the schedule should begin")] Uint32 StartMinute;
    [Write, Description("Specifies the number of times to repeat the crawl within a day")] Uint32 CrawlScheduleRepeatDuration;
    [Write, Description("Specifies the number of minutes between crawl repeats on a day")] Uint32 CrawlScheduleRepeatInterval;
    [Write, Description("For daily crawls, this is the number of days between crawls. For weekly this is the number of weeks between crawls")] Uint32 CrawlScheduleRunEveryInterval;
};

[ClassVersion("1.0.0.0"), FriendlyName("SPSearchContentSource")]
class MSFT_SPSearchContentSource : OMI_BaseResource
{
    [Key, Description("The name of the content source")] String Name;
    [Key, Description("The name of the search service app that this content source exists within")] String ServiceAppName;
    [Required, Description("The type of content source - currently only SharePoint, Website, File Shares and Business are supported"), ValueMap{"SharePoint","Website","FileShare","Business"}, Values{"SharePoint","Website","FileShare","Business"}] String ContentSourceType;
    [Write, Description("A list of the addresses this content source includes")] String Addresses[];
    [Write, Description("Should the crawler index everything, just the first site or page, or a custom depth (applies to websites only)"), ValueMap{"CrawlEverything","CrawlFirstOnly","Custom"}, Values{"CrawlEverything","CrawlFirstOnly","Custom"}] String CrawlSetting;
    [Write, Description("Should this content source use continuous crawl (SharePoint sites only)")] Boolean ContinuousCrawl;
    [Write, Description("What is the incremental schedule for this content source"), EmbeddedInstance("MSFT_SPSearchCrawlSchedule")] String IncrementalSchedule;
    [Write, Description("What is the full schedule for this content source"), EmbeddedInstance("MSFT_SPSearchCrawlSchedule")] String FullSchedule;
    [Write, Description("What is the priority on this content source"), ValueMap{"Normal","High"}, Values{"Normal","High"}] String Priority;
    [Write, Description("How many pages deep should the crawler go (-1 = unlimited, website sources only)")] Uint32 LimitPageDepth;
    [Write, Description("How many server hops should the crawler make (-1 = unlimtied, website sources only)")] Uint32 LimitServerHops;
    [Write, Description("Line of Business System and System Instance names")] String LOBSystemSet[];
    [Write, Description("Present if the source should exist, absent if it should not"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
    [Write, Description("Specify true if DSC is allowed to delete and recreate a content source to apply the correct settings, otherwise false will just report errors if a change can not be applied.")] Boolean Force;
    [Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount;
};

Verbose logs showing the problem (if applicable)

N/A

Suggested solution to the issue

Roll-back to the previous version or have the issue fixed in PSSA.

I have already created an issue in the PSSA repo: PowerShell/PSScriptAnalyzer#1192

@bergmeister
Copy link

bergmeister commented Mar 25, 2019

Thanks for reporting it, I added a comment to the created PSSA issue.

@PlagueHO PlagueHO added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Apr 30, 2019
@ykuijs
Copy link
Contributor Author

ykuijs commented Jun 18, 2019

This issue has been resolved in v1.18.1 which has been released recently

@ykuijs ykuijs closed this as completed Jun 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

No branches or pull requests

3 participants