Skip to content

Commit

Permalink
phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghalse committed May 20, 2024
1 parent 2d7b374 commit 3325819
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 99 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ and rules that are contained in the [`local/`](local/) directory. You
probably also want to re-skin it to match your own look and feel.

If it exists, the file [`local/xsltfunc.inc.php`](local/xsltfunc.inc.php)
is included. It is expected to define an `xsltfunc` class, and
is included. It is expected to define an `XsltFunc` class, and
any static public functions from this class are registered with
[XSLTProcessor](http://php.net/manual/en/xsltprocessor.registerphpfunctions.php)
so that they can be used in local XSLT stylesheets.
Expand Down
18 changes: 9 additions & 9 deletions certinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ function getOpenSSLInfo($pem, $arg = '-text')
'pem' => $pem,
'openssl' => getOpenSSLInfo($pem),
'validity' => [
'from' => xsltfunc::getCertDates($cert, 'from'),
'to' => xsltfunc::getCertDates($cert, 'from'),
'range' => xsltfunc::getCertDates($cert, 'both'),
'valid' => xsltfunc::checkCertValid($cert),
'from' => XsltFunc::getCertDates($cert, 'from'),
'to' => XsltFunc::getCertDates($cert, 'from'),
'range' => XsltFunc::getCertDates($cert, 'both'),
'valid' => XsltFunc::checkCertValid($cert),
],
'bits' => xsltfunc::getCertBits($cert),
'issuer' => xsltfunc::getCertIssuer($cert),
'subject' => xsltfunc::getCertSubject($cert),
'selfsigned' => xsltfunc::checkCertSelfSigned($cert),
'ca' => xsltfunc::checkCertIsCA($cert),
'bits' => XsltFunc::getCertBits($cert),
'issuer' => XsltFunc::getCertIssuer($cert),
'subject' => XsltFunc::getCertSubject($cert),
'selfsigned' => XsltFunc::checkCertSelfSigned($cert),
'ca' => XsltFunc::checkCertIsCA($cert),
'fingerprint' => preg_replace('/^.*Fingerprint=([0-9A-F:]+).*$/si', '$1', getOpenSSLInfo($pem, '-fingerprint')),
];

Expand Down
32 changes: 16 additions & 16 deletions local/fog-check-empty.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,97 +27,97 @@
whitespace will be considered blank for these purposes (PHP's trim() function).
-->

<xsl:template match="md:Company[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:Company[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:Company must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:GivenName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:GivenName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:GivenName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:OrganizationDisplayName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:OrganizationDisplayName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:OrganizationDisplayName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:OrganizationName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:OrganizationName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:OrganizationName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:ServiceDescription[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:ServiceDescription[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:ServiceDescription must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:ServiceName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:ServiceName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:ServiceName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:SurName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:SurName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:SurName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:EmailAddress[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:EmailAddress[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:EmailAddress must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="md:TelephoneNumber[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="md:TelephoneNumber[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">md:TelephoneNumber must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:Description[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:Description[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:Description must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:DisplayName[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:DisplayName[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:DisplayName must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:DomainHint[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:DomainHint[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:DomainHint must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:GeolocationHint[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:GeolocationHint[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:GeolocationHint must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:IPHint[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:IPHint[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:IPHint must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="mdui:Keywords[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="mdui:Keywords[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">mdui:Keywords must not be empty</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="shibmd:Scope[php:functionString('xsltfunc::checkStringIsBlank', text()) = 1]">
<xsl:template match="shibmd:Scope[php:functionString('XsltFunc::checkStringIsBlank', text()) = 1]">
<xsl:call-template name="error">
<xsl:with-param name="m">shibmd:Scope must not be empty</xsl:with-param>
</xsl:call-template>
Expand Down
42 changes: 21 additions & 21 deletions local/safire-common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<!-- Check the metadata certificates -->
<xsl:template match="ds:X509Certificate">
<xsl:variable name="use" select="ancestor::md:KeyDescriptor/@use"/>
<xsl:if test="php:functionString('xsltfunc::checkBase64', text()) = 0">
<xsl:if test="php:functionString('XsltFunc::checkBase64', text()) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -93,7 +93,7 @@
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="php:functionString('xsltfunc::checkCertSelfSigned',text()) = 0">
<xsl:if test="php:functionString('XsltFunc::checkCertSelfSigned',text()) = 0">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -103,12 +103,12 @@
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:text>should be self-signed. Got issuer of '</xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::getCertIssuer',text())"/>
<xsl:value-of select="php:functionString('XsltFunc::getCertIssuer',text())"/>
<xsl:text>'</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="php:functionString('xsltfunc::checkCertIsCA',text()) = 1">
<xsl:if test="php:functionString('XsltFunc::checkCertIsCA',text()) = 1">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -121,7 +121,7 @@
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="php:functionString('xsltfunc::getCertBits', text()) &lt; 2048">
<xsl:if test="php:functionString('XsltFunc::getCertBits', text()) &lt; 2048">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -131,12 +131,12 @@
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:text>key should be >= 2048 bits, found </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::getCertBits',text())"/>
<xsl:value-of select="php:functionString('XsltFunc::getCertBits',text())"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="php:functionString('xsltfunc::checkCertValid',text(),'from') = 0">
<xsl:when test="php:functionString('XsltFunc::checkCertValid',text(),'from') = 0">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -146,12 +146,12 @@
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:text>is not yet valid (begins </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::getCertDates',text(),'from')"/>
<xsl:value-of select="php:functionString('XsltFunc::getCertDates',text(),'from')"/>
<xsl:text>)</xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="php:functionString('xsltfunc::checkCertValid',text(),'to') = 0">
<xsl:when test="php:functionString('XsltFunc::checkCertValid',text(),'to') = 0">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:text>X509Certificate </xsl:text>
Expand All @@ -161,7 +161,7 @@
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:text>has expired or expires within a year (ends </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::getCertDates',text(),'to')"/>
<xsl:value-of select="php:functionString('XsltFunc::getCertDates',text(),'to')"/>
<xsl:text>)</xsl:text>
</xsl:with-param>
</xsl:call-template>
Expand All @@ -176,7 +176,7 @@
<xsl:text>) </xsl:text>
</xsl:if>
<xsl:text>validity: </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::getCertDates',text(),'both')"/>
<xsl:value-of select="php:functionString('XsltFunc::getCertDates',text(),'both')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
Expand Down Expand Up @@ -210,7 +210,7 @@
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="md:EmailAddress[php:functionString('xsltfunc::checkEmailAddress', text()) = 0]">
<xsl:template match="md:EmailAddress[php:functionString('XsltFunc::checkEmailAddress', text()) = 0]">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select="substring-after(text(), 'mailto:')"/>
Expand Down Expand Up @@ -265,7 +265,7 @@

<xsl:template match="mdui:*[substring(name(), string-length(name()) - 2) = 'URL']">
<!-- Check that *URL point at web servers that exist -->
<xsl:if test="php:functionString('xsltfunc::checkURL', text()) = 0">
<xsl:if test="php:functionString('XsltFunc::checkURL', text()) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select='local-name()'/>
Expand All @@ -277,7 +277,7 @@

<xsl:template match="md:OrganizationURL">
<!-- Check that *URL point at web servers that exist -->
<xsl:if test="php:functionString('xsltfunc::checkURL', text()) = 0">
<xsl:if test="php:functionString('XsltFunc::checkURL', text()) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select='local-name()'/>
Expand All @@ -299,7 +299,7 @@
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="php:functionString('xsltfunc::checkURL', text()) = 0">
<xsl:when test="php:functionString('XsltFunc::checkURL', text()) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select='name()'/>
Expand All @@ -313,21 +313,21 @@
<xsl:template match="md:*[@Location]">
<!-- Check @Location uses a valid certificate -->
<xsl:choose>
<xsl:when test="starts-with(@Location, 'https:') and php:functionString('xsltfunc::checkURLCert', @Location, 0) = 0">
<xsl:when test="starts-with(@Location, 'https:') and php:functionString('XsltFunc::checkURLCert', @Location, 0) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select='local-name()'/>
<xsl:text> Location SSL verification with cURL: </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::checkURLCert',@Location, 0, 1)"/>
<xsl:value-of select="php:functionString('XsltFunc::checkURLCert',@Location, 0, 1)"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with(@Location, 'https:') and php:functionString('xsltfunc::checkURLCert', @Location, 1) = 0">
<xsl:when test="starts-with(@Location, 'https:') and php:functionString('XsltFunc::checkURLCert', @Location, 1) = 0">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:value-of select='local-name()'/>
<xsl:text> Location fails modern-browser SSL tests: </xsl:text>
<xsl:value-of select="php:functionString('xsltfunc::checkURLCert',@Location, 1, 1)"/>
<xsl:value-of select="php:functionString('XsltFunc::checkURLCert',@Location, 1, 1)"/>
<xsl:text> See https://www.ssllabs.com/ssltest/?d=</xsl:text>
<xsl:value-of select="substring-before(substring-after(@Location, '://'), '/')"/>
</xsl:with-param>
Expand All @@ -336,7 +336,7 @@
</xsl:choose>

<!-- Check that @Location point at web servers that exist -->
<xsl:if test="php:functionString('xsltfunc::checkURL', @Location) = 0">
<xsl:if test="php:functionString('XsltFunc::checkURL', @Location) = 0">
<xsl:call-template name="error">
<xsl:with-param name="m">
<xsl:value-of select='local-name()'/>
Expand All @@ -347,7 +347,7 @@
</xsl:template>

<!-- Check entityID -->
<xsl:template match="md:EntityDescriptor[php:functionString('xsltfunc::checkURL', @entityID) = 0]">
<xsl:template match="md:EntityDescriptor[php:functionString('XsltFunc::checkURL', @entityID) = 0]">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:value-of select='@entityID'/>
Expand Down
Loading

0 comments on commit 3325819

Please sign in to comment.