Section 9. Notwithstanding the provisions of any general or special law to the contrary, any information, record, or particular part thereof, obtained by the department or by the head of the fire department or by their respective personnel or contractors pursuant to the provisions of this chapter, upon request, shall be confidential and not be considered to be a public record when it is determined by the department or by the head of the fire department, as the case may be, that such information, record, or particular part thereof, if made public, would divulge a trade secret. This section shall not prevent disclosure of any information necessary for an enforcement action or to comply with Federal law or regulations. The exclusive remedy for any person aggrieved by a determination of the department or of the head of the fire department, as the case may be, pursuant to this section shall be a civil action in the nature of certiorari pursuant to section four of chapter two hundred and forty-nine; provided, that the action shall be commenced within thirty days of the date of the determination. Notwithstanding the provisions of any general or special law to the contrary, any information, record, or particular part thereof, obtained by the department, or by the head of the fire department or by their respective personnel or contractors pursuant to the provisions of this chapter shall be a public record unless it is not a public record pursuant to this section or pursuant to any other law.