Skip to content

Commit eb79ca0

Browse files
committed
Merge branch 'p720'
2 parents 063c257 + 82e55e3 commit eb79ca0

57 files changed

Lines changed: 883 additions & 1069 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Application.cfc

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@
2727
<cfif structKeyExists(url, "furl") AND url.furl EQ "/pingFU">
2828
<cfcontent type="text/plain" variable="#ToBinary( ToBase64('PING FU SUCCESS') )#" reset="Yes">
2929
</cfif>
30-
31-
30+
31+
<!--- healthcheck live endpoint --->
32+
<cfif structKeyExists(url, "furl") AND url.furl eq "/healthcheck/live">
33+
<cfset healthcheckLive()>
34+
</cfif>
35+
36+
3237
<!--- run the active project's constructor --->
3338
<cfset this.projectConstructorLocation = getProjectConstructorLocation(plugin="webtop") />
3439
<cfinclude template="#this.projectConstructorLocation#" />
@@ -114,11 +119,11 @@
114119
<cfparam name="cookie.hasSessionScope" default="false" />
115120

116121
<cfif NOT isBoolean(cookie.sessionScopeTested)>
117-
<cfset cookie.sessionScopeTested = false>
122+
<cfcookie name="sessionScopeTested" value="false" expires="never" httpOnly="true" />
118123
</cfif>
119124

120125
<cfif NOT isBoolean(cookie.hasSessionScope)>
121-
<cfset cookie.hasSessionScope = false>
126+
<cfcookie name="hasSessionScope" value="false" httpOnly="true">
122127
</cfif>
123128

124129
<cfif not len(cgi.http_user_agent) or (cookie.sessionScopeTested and not cookie.hasSessionScope) or reFindAny(this.botAgents,lcase(cgi.HTTP_USER_AGENT)) or arrayFind(this.botIPs,cgi.remote_addr)>
@@ -127,8 +132,8 @@
127132

128133
<cfif not cookie.sessionScopeTested>
129134
<cftry>
130-
<cfcookie name="sessionScopeTested" value="true" expires="never" />
131-
<cfcookie name="hasSessionScope" value="false" expires="never" />
135+
<cfcookie name="sessionScopeTested" value="true" expires="never" httpOnly="true" />
136+
<cfcookie name="hasSessionScope" value="false" expires="never" httpOnly="true" />
132137
<cfcatch></cfcatch>
133138
</cftry>
134139
</cfif>
@@ -137,8 +142,8 @@
137142

138143
<cfif not cookie.sessionScopeTested><!--- Sessions are OK for this user, set the cookie --->
139144
<cftry>
140-
<cfcookie name="sessionScopeTested" value="true" expires="never" />
141-
<cfcookie name="hasSessionScope" value="true" expires="never" />
145+
<cfcookie name="sessionScopeTested" value="true" expires="never" httpOnly="true" />
146+
<cfcookie name="hasSessionScope" value="true" expires="never" httpOnly="true" />
142147
<cfcatch></cfcatch>
143148
</cftry>
144149
</cfif>
@@ -246,8 +251,35 @@
246251

247252
<cfreturn false />
248253
</cffunction>
249-
250-
254+
255+
256+
<cffunction name="healthcheckReady" output="false">
257+
<!---
258+
readiness indicates that the application has been initialised and is ready to handle requests
259+
(e.g. ready to be brought into a load balancer)
260+
--->
261+
<!--- test the application --->
262+
<cfif NOT structKeyExists(application, "bInit") OR application.bInit eq false>
263+
<cfheader statuscode="503" statustext="Unavailable: Application has not started">
264+
<cfabort>
265+
</cfif>
266+
267+
<!--- return a 200 OK --->
268+
<cfheader statuscode="200" statustext="OK">
269+
<cfabort>
270+
</cffunction>
271+
272+
<cffunction name="healthcheckLive" output="false">
273+
<!---
274+
liveness indicates that the application is in a healthy, live state (and the JVM is healthy)
275+
failing this test means that the application server may need to be restarted
276+
--->
277+
<!--- return a 200 OK --->
278+
<cfheader statuscode="200" statustext="OK">
279+
<cfabort>
280+
</cffunction>
281+
282+
251283
<cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false" hint="Fires when the application is first created.">
252284

253285
<cfset var qServerSpecific = queryNew("blah") />
@@ -420,6 +452,18 @@
420452
<cffunction name="OnRequestStart" access="public" returntype="boolean" output="false" hint="Fires at first part of page processing.">
421453
<cfargument name="TargetPage" type="string" required="true" />
422454

455+
<!--- healthcheck ready endpoint --->
456+
<cfif structKeyExists(url, "furl") AND url.furl eq "/healthcheck/ready">
457+
<cfset healthcheckReady()>
458+
</cfif>
459+
460+
<!--- block requests to /farcry paths with the exception of webtop --->
461+
<cfif left(cgi.script_name, 7) eq "/farcry" AND NOT left(cgi.script_name, len(application.url.webtop)) eq application.url.webtop>
462+
<cfset oError = createobject("component","farcry.core.packages.lib.error") />
463+
<cfset oError.showErrorPage("404 Page missing",oError.create404Error("Bad request")) />
464+
<cfabort />
465+
</cfif>
466+
423467
<!--- If a session switch was requested, do that now --->
424468
<cfif structKeyExists(url, "switchsession")>
425469
<cfset application.fc.lib.session.switchSession(url.switchsession) />
@@ -462,7 +506,7 @@
462506
<cfif not listcontains(server.stFarcryProjects[application.projectDirectoryName].domains,cgi.http_host)>
463507
<cfset server.stFarcryProjects[application.projectDirectoryName].domains = listappend(server.stFarcryProjects[application.projectDirectoryName].domains,cgi.http_host) />
464508
</cfif>
465-
<cfset cookie.currentFarcryProject = application.projectDirectoryName />
509+
<cfcookie name="currentFarcryProject" value="#application.projectDirectoryName#" httpOnly="true">
466510

467511
<!--- Checks to see if the user has attempted to flick over to administrate a different project on this server. --->
468512
<cfif structKeyExists(url, "farcryProject")
@@ -535,7 +579,9 @@
535579
<cfset var oError = "" />
536580

537581
<!--- increase the request timeout a little, in case the error was caused by a request timeout --->
538-
<cfif structkeyexists(server,"railo")>
582+
<cfif structkeyexists(server,"lucee")>
583+
<cfsetting requesttimeout="#getPageContext().getRequestTimeout() + 10000#" />
584+
<cfelseif structkeyexists(server,"railo")>
539585
<cfsetting requesttimeout="#getPageContext().getRequestTimeout() + 10000#" />
540586
<cfelseif structkeyexists(server,"coldfusion")>
541587
<cfsetting requesttimeout="#CreateObject("java", "coldfusion.runtime.RequestMonitor").GetRequestTimeout() + 10#" />
@@ -756,7 +802,7 @@
756802
<!--- If all else fails... --->
757803
<!--- 1. See if the user has a cookie telling us what project to look at. --->
758804
<cfif structKeyExists(url, "farcryProject") AND len(url.farcryProject)>
759-
<cfset cookie.currentFarcryProject = url.farcryProject />
805+
<cfcookie name="currentFarcryProject" value="#url.farcryProject#" httpOnly="true">
760806
</cfif>
761807
<cfif arguments.plugin EQ "webtop" AND structKeyExists(cookie, "currentFarcryProject")>
762808
<cfif fileExists(expandPath("/#currentFarcryProject#/farcryConstructor.#arguments.fileExtension#"))>

packages/cdn/local.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,18 @@
276276
<cffunction name="ioGetDirectoryListing" returntype="query" access="public" output="false" hint="Returns a query of the directory containing a 'file' column only. This filename will be equivilent to what is passed into other CDN functions.">
277277
<cfargument name="config" type="struct" required="true" />
278278
<cfargument name="dir" type="string" required="true" />
279+
<cfargument name="listinfo" type="string" required="false" default="name" hint="name or all" />
279280

280281
<cfset var qDir = "" />
281282

282-
<cfdirectory action="list" directory="#getFullPath(config=arguments.config,file=arguments.dir)#" recurse="true" type="file" listinfo="name" name="qDir" />
283+
<cfdirectory action="list" directory="#getFullPath(config=arguments.config,file=arguments.dir)#" recurse="true" type="file" listinfo="#arguments.listinfo#" name="qDir" sort="name" />
283284

284285
<cfquery dbtype="query" name="qDir">
285-
SELECT '#arguments.dir#/' + name AS file
286+
SELECT '#arguments.dir#/' + name AS file, *
286287
FROM qDir
287288
WHERE not name like '%/.%'
288-
ORDER BY name
289289
</cfquery>
290-
290+
291291
<cfreturn qDir />
292292
</cffunction>
293293

0 commit comments

Comments
 (0)