A law enforcement officer (LEO) generally has the right to frisk you for weapons if he has any lawful business with you. In the process, if he finds a joint in your pocket, he can bust you for it.
Generally, LEO must have either a reasonable suspicion or probable cause that you have committed a crime, or that criminal activity is afoot, in order to stop your car. Once stopped, LEO may search a vehicle if he has probable cause that it contains contraband. Police may search a vehicle in cases of a routine traffic stop for a minor violation like speeding.
LEO can search your person, your car or the place where you are found after you have been lawfully arrested. This is called a search incident to a lawful arrest. A scenario to consider: You get a DUI. While searching your vehicle, after arresting you for DUI, the officer finds some valiums not in a pill bottle and for which you do not have a prescription. He takes you to jail on the DUI but does not arrest you on the pills. You bond out. He sends the pills to the crime lab who confirms that they are valium. He gets an arrest warrant and serves it on you at your home, searches your home incident to the arrest for possession of valium, and finds your grow room.
LEO can search any area in which evidence of the commission of a crime is plain view. Not only is this the bloody knife on the front seat situation, but too, the pot plant on your window sill or the beer can in your cup holder.
LEO may search your house or your car if you give your consent to such a search.
Finally, LEO can search your home if he has probable cause that a crime has been committed and there are “exigent circumstances.” Exigent circumstances are those circumstances which would cause a reasonable person to believe that prompt action, such as entry, is necessary to prevent physical harm to the officers or other persons, the destruction of relevant evidence, the escape of the suspect, or some other consequence improperly frustrating legitimate law enforcement efforts.